regarding databases and models.py relation

13 views
Skip to first unread message

Chess Lectures

unread,
Mar 31, 2023, 10:16:17 AM3/31/23
to Django users
when we create a table in database , we create through models.py . 
we migrate and apply the changes .
Issue arises as after creation of table -> i tried to add a coloum manually to the db , and wrote the col name in models.py and in views.py as it was a time field added, so
data was getting inserted in the database correctly as desired .

Note -> NO MIGRATIONS WERE APPLIED YET .

now I wanted to create a new col named say x , i wrote in models , views nd then applied migrations -> it started throwing error -> i stopped the creation of new colm .

i applied migrations again for checking if there is any issue -> it showed ypu have a unapplied migration that was related to the manuall chnage i had done .

so i tried migrating but it failed -> colm name already exists .

MY REQUEST -> ADD A FEAUTURE THAT CAN SYNCHRONISE THE MANUALL CHNAGES IN DATABASE WITH DJANGO ORM .
SO we dont fall in the migration error -> it by default migrates when we make manuall chnages in the database .


if my request is valid , let me know for any solutions, if it not valid ,please still let me know why ?

Thank you in advance
 
  

Ryan Nowakowski

unread,
Apr 3, 2023, 9:44:30 AM4/3/23
to django...@googlegroups.com
Most folks either synchronize models to the database using migration or sync the database to models using inspectdb.

I haven't seen too many use cases for bidirectional synchronization like you're asking for here.
Reply all
Reply to author
Forward
0 new messages