0
How to insert date and time field in model.py and when submitting form both should be saved in the database django?
Its about django framework i m stuck in this date and time field.
3 ответов
+ 2
You can use django DateTimeField to store datetime.
```
date_time = models.DateTimeField()
```
If you want that it should auto add current date time then
```
date_time = models.DateTimeField(auto_now_add = True)
```
In above case if you want that this field should not appear in form, then don't forget to exclude this field.
0
Do you use django forms to store your data?
0
In addition to my previous answer, there is one more option for date time field i.e, "auto_now", this field will automatically save current time whenever the record is changed or created.
While "auto_now_add" only saves the time when the record is created.
*DON'T USE BOTH OPTIONS IN SAME FIELD*