33๐
You have already some rows without created_at
value.
But when you added following field and run migration
created_at = models.DateTimeField( auto_now_add = True)
It expects the existing row has created_at
value. So, It warns you at the time of migrations.
To solve this problem.
You can choose the 1st option which says Provide a one-off default now (will be set on all existing rows)
.
By choosing the 1st option you are asking for value. Here you can enter timezone.now()
. It will populate existing rows with the current timestamp.
9๐
Delete the migration file in app and you can makemigrtion process at the time no error raises, It raises due to the reason of previously created time object.
- [Django]-Add custom form fields that are not part of the model (Django)
- [Django]-Is it possible to generate a diagram of an entire Django webapp?
- [Django]-Django i18n: Make sure you have GNU gettext tools
1๐
if you are using a sqlite database you can omit it and again make it,
or you can write null=True as an argument for your DateTimeFeild()
i suggest you the second one that i have done before
- [Django]-How to make python on Heroku https only?
- [Django]-Skip system checks on Django server in DEBUG mode in Pycharm
- [Django]-How to create virtual env with python3
1๐
you can create two migrations,
- the first one sets a default value,
- the second remove the default and add the auto_now_add
- [Django]-One app with many models vs. many apps with single model
- [Django]-Dynamically adding a form to a Django formset
- [Django]-Django models, custom functions
0๐
That is because auto_now_add = True make django determine every instance of the model should have a value instead of null.
- [Django]-Django: remove a filter condition from a queryset
- [Django]-Convert an IP string to a number and vice versa
- [Django]-How to make an Inner Join in django?
0๐
when migrating use:
- python manage.py makemigrations
- python manage.py migrate โrun-syncdb
- [Django]-How to redirect on conditions with class based views in Django 1.3?
- [Django]-Sending JSON using the django test client
- [Django]-How to implement followers/following in Django