date = models.DateTimeField(auto_now_add=True, blank=True)
Here is what the above code is Doing:
1. We’re importing the models module from the django.db package.
2. We’re defining a new class called Post, and giving it some attributes.
3. Each attribute is represented by an instance of a field class – e.g. CharField for character fields and DateTimeField for datetimes.
4. Some of these field classes have required arguments. CharField, for example, requires that you give it a max_length. That’s used not only in the database schema, but in validation, as we’ll soon see.
5. The name of each field instance (e.g. title or pub_date) is the field’s name, in machine-friendly format. You’ll use this value in your Python code, and your database will use it as the column name.
6. You can use an optional first positional argument to a Field to designate a human-readable name. That’s used in a couple of introspective parts of Django, and it doubles as documentation. If this field isn’t provided, Django will use the machine-readable name. In this example, we’ve only defined a human-readable name for title, because title is more meaningful than pub_date.