2👍
✅
Sounds like your migration files are messed up. When you do a migration, django would create a migration file that records what you did. So in short, you changed your model code many times, but you never changed your migration file, or you are creating duplicate migration files.
The following should be what you want,
birthdate = models.DateField(null=True, blank=True)
But as you noticed, cleaning up all migration files that related to this change and create a new one should solve the problem.
1👍
What you have tried should work:
birthdate = models.DateField(null=True, blank=False)
This allows the database to accept null values (which it does during the migration) and blank means that django will not accept empty values from forms.
Make sure to delete migrations that have been made but not applied. Also try deleting all .pyc’s in your project.
- [Django]-How to create a new table using model
- [Django]-Django convert timedelta to integer in annotation
- [Django]-How to install Mezzanine on Webfaction Server
- [Django]-How to dynamically delete object using django formset
- [Django]-Formatting inline many-to-many related models presented in django admin
- [Django]-Filtering by calculated (extra()) fields
- [Django]-How to define models/serializers correctly for Django REST Framework?
- [Django]-Unresolved Imports in VS Code Django Project
Source:stackexchange.com