I'm working on my first django project following along with a youtube tutorial.
In models.py while following along I made a typo...
crated_at = models.DateTimeField(default=datetime.now)
"crated_at" should be "created_at". The typo is reflected in my migrations. I tried changing both models.py and the migrations py file but it leads to an error so I changed it back to "crated". I think the problem is that the database saves the information as "crated_at". I don't want to delete the migration and redo the migrations because from what I read the database is already labeled and it won't fix the problem.
Also, I don't mind if it's left as "crated_at" in models.py and the migrations, but at least I would like it to see "created at" when I'm signed in as admin.
I want to move on but when I sign in as admin "crated at" is staring me in the face. I feel like this is a good learning moment.
Thank you.
CodePudding user response:
I suggest keeping (restoring) the original migration with the typo, then:
- Fix the typo in your model
- Generate a new migration that contains the fix for the typo
CodePudding user response:
Thanks for the answer!
Earlier, I edited the typo in manage.py and the migration file. Also, I did not run a makemigration and a migrate. This time, I changed the typo in manage.py, ran makemigration and migrate, and a new migration py file was made. "Created at" is now showing on the admin site. Thank you.