Web2py -------------- example of using web2py to write django, web2pydjango
Follow the previous article to create an app named polls.
The file structure is as follows:
Then web2py automatically adds some code to it.
We need to remove some, such as the controllers and defualt. py index methods;
Corresponding to default/index.html under the views folder
In fact, it is not difficult to see the ing betwee
default content inherited from Base.html is displayed. {% Block content%}{% include'ad.html'%} #引用ad. html template. this isIndex page,welcome! {% Endblock%}Change the function that processes the request to return the template file to the client: (Of course, the content is rendered)In the app/views.py from Import def Home (Request): return'home.html' )Viii. Start-up project:[email protected] mysite]$Python manage.py runserver 0.0.0.0:8000Performing system checks ... System Check identified
Unique_together
This metadata is a very important one. It is equivalent to a federated constraint on the database.
For example, suppose you have a user table that holds information about the user's name, date of birth, gender, place of origin, and so on. Requirements are all users only do not repeat, but now there are several called "Zhang Wei", how to distinguish them. (Don't talk to me about the primary key, this is not the problem)
We can set no
Simple python django framework development example, pythondjango
Create the views. py file in the/home/ubuntu/mysite directory as follows:
from django.http import HttpResponse,Http404import datetimeimport osdef sayhi(request): return HttpResponse('Hello World,this is my first Web page')
def current_time(request): ow = datetime.datetime.now() html = '
def cpu(request): cpu_status = os.
Web2py -------------- example of using web2py to write django, web2pydjango
Model Creation
Under models and where polls. py
The file content is as follows:
1 #-*-coding: UTF-8-*-2 pollsdb = DAL (uri = 'sqlite: // polls. db') 3 4 pollsdb. define_table ('Question ', 5 Field ('Question _ text', 'string', length = 200), 6 Field ('pub _ date', 'datetime '), 7 format = '% (question_text) s') 8 9 pollsdb. define_
|Safe}}; //Remember to use safe to filter oh, otherwise you will get an error. //The following code puts each part of the list to the head and tail $('#list'). prepend (list[0]); $('#list'). Append (list[1]); Console.log ('---traverse List Method 1---'); for (varI=List.length- 1; I>= 0; I--){ //right mouse button, audit element, select Console to see the value enteredConsole.log (List[i]); }; Console.log ('---Traverse both the index and the content, using the
I. Setting up a virtual directory in a Web applicationIi. in the virtual directory, a file, Web. config, reads as follows: XML version= "1.0"?> Configuration> system.webserver> handlers> Clear/> Addname= "Staticfile"Path="*"verb="*"Modules= "Staticfilemodule,defaultdocumentmodule,directorylistingmodule"ResourceType= "either"requireaccess= "Read" /> handlers> system.webserver>Configuration> Ways to set up a static virtual directory in an Azure web app
This semester I learned a course "Information Retrieval", that is, the legendary search engine.
Big jobs naturally let us build a small search engine ourselves. The theme was born.
I also learned and used it. I will share with you what I learned in this process. please correct me if I have not said anything.
This is an example of my search engine. You can click here to download the source code of all the file boxes.
According to the process, I wil
Tags: djangoTitle, with Python manage.py migrate times wrong, hint missing Mysql-python package. Confirm that this is still the case after installation.Baidu after the solution:1.pip Install Pymysql2. Open the __init__.py under Project, default is empty, change to the followingPymysql
Pymysql.install_as_mysqldbSo, the migration succeedsThis article is from the "Call Beast" blog, please make sure to keep this source http://joyshow.blog.51cto.com/12477692/1964148One
self.choice_text 2, operation in admin.py, temporarily do not know how to integrate the questionnaire name + title + options on the same page Class Questioninline (admin. Tabularinline): #为了在问卷页面输入你的问卷题目这是默认有6题 Model = Questionproblem Extra = 6Class Choiceinline (admin. Tabularinline): 4 options per question Model = Choice Extra = 4Class Questiionadmin (admin. Modeladmin): FieldSets = [ (None, {' Fields ': [' Problem_name ']}), #在后台可以看到问题名称 (None, {' Fields '
DescriptionCreate a new Django program, this article is chain.The following is a simple example where the actual application can be modified according to its own platform.After opening the first page, you need to enter 1, backstage to log in to the host, and then return the results of the login.Normal project can post the host and login account, to determine the permissions, and then go backstage to read th
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.