Label: id = models. Integerfield (Primary_key = True) Report:
Null: The default setting is False. It is not normally used on character fields, such as Charfield,textfield. Character fields If no value returns an empty string.
Blank: Whether the field can be empty. If False, you must have a value
Choices: A 2-dimensional tuple that is used to select values. The first value is the actual stored value, and the second is used to make the
How do I add a field to a model that Django already exists?First find the corresponding model name in the model.py file, add the fields that need to be addedThen python manage.py sqlall database nameFind the SQL statement of the newly added field and record itExecute the Python manage.py shell againExecute the following command from Import connectioncursor=connec
Class talk (models. Model ):Time = models. datetimefield ()Content = models. textfield ()
After the above model is defined, the information generated by the table cannot be viewed using manage. py syncdb. Of course, the generated table is not seen in the MySQL database. Later I found that it was a problem with textfield. MySQL needed special settings to use this field. Later I saw the following in the Django
Transferred from: http://my.oschina.net/u/993130/blog/209460
1. Multi-table Connection query: When I know this, I feel that Django is too nx. class A (models. Model):Name = models. Charfield (U ' name ')Class B (models. Model):
AA = models. ForeignKey (A)
# AA = models. ForeignKey (A, Primarykey=true) #注: In a real database table structure, the name of the corresponding field is added by
Error message:Fielderror:cannot Resolve keyword ' entry ' into field. Choices Are:xx,xx,xx,Models:Class Ami (models. Model):... class Amiadmin (admin.Modeladmin): List_display = [' id ',....]#list_filter = (...) Class Entry (models. Model): MSN = models. ForeignKey (Ami) ...Workaround:Several attempts to modify the model have been found to be unrelated to the model, the problem caused by the list_filter in Modeladmin, commented outProblem solving, pro
Delete a field
It is much easier to remove a field from the model than to add it. Delete The fields, just a few steps:
Delete the fields, and then restart your Web server.
Remove the fields from the database with the following command:
ALTER TABLE books_book DROP COLUMN num_pages;
Make sure that the operation is in the correct order. If you delete a fie
# 1.models.py ... = models. Choicefield ( choices=[ (" male "), (" female ") ] # index.html ... {{Model class object. Get_sex_display}} # show men and women, not to be;The settings in the Choices field are displayed in HTML | Django
, ' app__apptype_name ': u ' Wapsearch '}] If you just want to get App_id can do this, the following three methods are the same, just return the result name corresponding to your query statement LogTypeDef.objects.filter (pk=6). VALUES (' PK ', ' app_id ')LogTypeDef.objects.filter (pk=6). VALUES (' PK ', ' app ')LogTypeDef.objects.filter (pk=6). VALUES (' PK ', ' app__id ')Note that when the association is many-to-many, it will only help you to list a single article, and will not help you
Gridview supports a total of seven field types. The field should have been called "column", but ASP. NET 2.0 uses another name, "field". It is not intuitive to name the priest, because unknown people do not know what field represents, but since ASP. NET 2.0 uses the
uniqueidentifier.The Timestamp is used to represent the sequence of SQL Server activities in a binary projection format. Timestamp data is not related to inserting data or date and time.The Bit is made up of 1 or 0. When representing true or false, on, or off, use the Bit data type. For example, ask if a client request for each visit can be stored in a column of this data type.The uniqueidentifier consists of 16-byte hexadecimal digits that represent a globally unique. GUIDs are useful when the
Text nvarchar (N)
Note ntext
Number (long integer) int
Integer smallint
Number (single precision) Real
Number (Double Precision) float
Number (byte) tinyint
Currency Money
Date smalldatetime
Boolean
Appendix: the script for converting to SQL.
Alter table tb alter column AA byte number [bytes]Alter table tb alter column AA long number [long integer]Alter table tb alter column AA short number [integer]Alter table tb alter column AA single number [single precisionAlter table tb alter column AA dou
This article mainly introduces the MySQL data type and common field attribute summary. This article summarizes the date and time data types, numerical data types, string data types, and so on. For more information, see
Preface
For example, in C ++, how many bytes are required to define the int type and how many bytes
Description of SQL Server Field Types
The following describes the Field Types of SQL Server 7.0 and later versions. For more information about the field types of SQL Server 6.5, see the description provided by SQL Server.
Bit:
The following articles mainly introduce the differences between MySQLtext and blob field types. At the same time, this article also introduces the practical application of MySQLtext and blob field types, if you are interested in the actual operations related to the MySQLtext and blob
Development of Custom Field Types-Level 2 combox Linkage
I found some information aboutCustom Field TypeDevelopedArticle. It is found that there are few articles about this part in Moss development. However, this is enough for us to get started.
1. Create a moss2007 Custom Field Type instance
2. Create a moss2007
value is only in English, you can select varchar. If the field value contains many double-byte (Chinese, Korean, etc.) characters, use nvarchar.Differences between char varchar nvarcharOnline help:In general, if it contains Chinese characters, use nchar/nvarchar. If it contains English letters and numbers, use char/varchar.** A good summaryMany developers often do not consider the char and varchar types wh
.
OLE Object
From other Windows application-based object linking and embedding, such as Excel tables, Word documents, pictures, sounds, etc., File Max 1GB
Hypertext links
Create a field that stores hyperlinks that can be linked to a local UNC or network URL field, consisting of 4 parts: display text, address, sub-address, ScreenTip, with # interval, up to 2048 charact
Http://www.cnblogs.com/LDaqiang/articles/1157998.html due to changes in demand, the field type number (8,2) is now changed to char.The general idea is as follows:Rename the field name of the type to back up, and then add a field with the same name as the field name of the type you want to change (the original
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.