The development environment is:Apache + python + django+ Eclipse (development environment)To achieve the purpose:On the Web page, add the upload file control. Then read the CSV file and parse the CSV file.Operation Steps:Django is the design pattern of MVC (model M, view V, controller C)1. Build your own model from Django's basic model.Add the following code to the myforms.py file, and the data for this model can be used in the HTML-displayed
First of all to introduce jquery files, can be introduced online, you can also download offline add to their own staticfilesThe demo here is to add the offlineNote that this sentence is to be added to the front of the jquery script that you wroteAnd then write a simple form.A simple form with a single user name and password and a submit button note I'm here for the formID is formadd looks very shabby ~And then add our
In the previous blog, we learned that if we create Django, here we mainly talk about how to pass data to the backgroundIn the URL file, import views from app01 and create URLs (R ' ^login/', views.login) from Import Admin from Import URL from Import = [url (r ' ^admin/', admin.site.urls), URL (r'^login/', Views.login),]Next, the login function in the app01.views operationBrief description: When the first time to enter Views.login is get,
) = models. ForeignKey ('usertype')Create a database table to execute the following two statements:views.py to generate data through loops fromDjango.shortcutsImportRender#From django.shortcuts import HttpResponse fromApp01ImportModels fromDjangoImportFormsclassIndexform (forms. Form):#C = { #(1, ' CEO '), #(2, ' COO ') # }c = Models. UserType.objects.all (). Values_list ('ID','caption') user_type_id= Forms. Integerfield (widget=forms. Sel
First look at the following simple method: Fromdjango.httpimporthttpresponsedefhello (Request ): returnhttpresponse ("Helloworld") We can get a lot of information request from this request. meta is a Python dictionary that contains header information for all HTTP requests, such as the user's IP address and user agent (usually the name and version number of the browser). Note that the complete list of header information depends on the header information sent by the user and the header informati
Here's the answer.Http://www.qttc.net/201209211.htmlSummary is1. Add {% Csrf_token%} to the form you want to submit in the templatemethod= "POST"> {% Csrf_token%} {{form.as_p}} type= "Submit" name= "OK"> form >2. Put the views in theRender_to_response (' h1.html ', {' form ': Form})Change intoRender_to_respo
Method of checking Form form is_valid ()We found that there are only two method methods in this function, which finally returns TRUE or False.Let's go in. Is_bound property, which determines whether the transmitted data is not empty and the upload file is not emptyPoint in. Errors found that this is a method disguised as a property, using the built-in decorator properties,Here is a simple logic to judge eve
Two HTML pages, stored under the Templates folder under an app.Index.htmlSubmitWhen you click the "Submit" button, the second page is hello.html to display the contents of the text boxThe principle is to invoke the appropriate method through the action of the formThe index.html code is as follows:formAction= "/ok/"Method= "POST"> inputtype= "text"name= "Q"> Buttontype= "Submit">SubmitButton>form>The action "/ok/" is actually called
Index.htmlPlease enter the number {{result}}Enter numbers in the form to print in the consolehello.pydef hi (Request):dataset={' result ': ' must enter Number '}Print request. Post.get (' Mustnumber ')Return Render_to_response ("index.html", DataSet)This article is from the DBA Sky blog, so be sure to keep this source http://9425473.blog.51cto.com/9415473/1702061The value of the Django print
Default Value of Django model. py form can be blank by default, djangomodel. py
Field. null
The default value is null = False. In this case, NULL data cannot be input, but it can be a null character.
If BooleanField wants a null data type, you can select NullBooleanField
Field. blank
The default value is blank = False, indicating that the default value is not allowed to be blank. If blank = True, the
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.