Advertisement
File Types | Description |
---|---|
AutoField | An IntegerField that automatically increments according to available IDs. Note: Usually you won’t need to use this directly, a primary key field will automatically be added to your model if you don’t specify. |
BigAutoField | A 64-bit integer field, much like an AutoField except that it is guaranteed to fit numbers from 1 to 9223372036854775807. |
BigIntegerField | A 64-bit integer field, much like an IntegerField except that it is guaranteed to fir larger numbers from -9223372036854775808 to 9223372036854775807. |
BinaryField | A field used to store raw binary data. |
BooleanField | A true/false field. The default value of BooleanField is None, when Field.default isn’t defined. |
CharField | A string field, for small to large sized strings. For a large amounts of text, please use TextField class.. |
DateField | A date field represented in Python by a datetime.date instance. |
DateTimeField | A date and time field represented in Python by a datetime.datetime instance. |
DecimalField | A fixed-precision decimal number field, represented in Python by a Decimal instance. |
DurationField | A field for storing periods of time. |
EmailField | An e-mail field that checks that the value is a valid email address. |
FileField | A file-upload field. |
FieldFile | When you access a FileField on a model, you are given an instance of FieldFile as a proxy for accessing a file. |
FilePathField | A file path field, whose choices are limited to the filenames in a certain directory on the filesystem. |
FloatField | A floating-point number field, represented in Python by a float instance. |
ImageField | A file-upload field which inherits all attributes and methods from FileField, but also validates that the uploaded object is a valid image. |
IntegerField | An integer field, which values from -2147483648 to 2147483647 in all databases supported by Django. |
GenericIPAddressField | An IPv4 or IPv6 address, in string format. |
NullBooleanField | Same as BooleanField with null=True. |
PositiveIntegerField | Same as IntegerField, but must be either positive or zero (0) and it values from 0 to 2147483647 in all databases supported by Django. |
PositiveSmallIntegerField | Same as PositiveIntegerField, but only allows values from 0 to 32767 in all databases supported by Django. |
SlugField | Used to create a short label for something, containing only letters, numbers, underscores or hyphens. It is generally used in URLs. |
SmallIntegerField | Same as IntegerField, but only allows values from -32768 to 32767 in all databases supported by Django. |
TimeField | A time field which is represented in Python by a datetime.time instance. |
URLField | A URL field. |
UUIDField | A field for storing universally unique identifiers(UUID), it is based on Python’s UUID class. |
from django.db import models
# Creating our model class - Customer_Info
class Customer_Info(models.Model):
name = models.CharField(max_length=30)
dob = models.DateField(max_length=50)
email = models.EmailField(max_length=30)
age = models.IntegerField(max_length=50)
married = models.BooleanField(max_length=30)
def __str__(self):
return (self.name + ', ' + self.address + ', ' + self.city + ', ' + self.state + ', ' + self.country)
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement