Problem: My problem was python manage.py makemigrations invoked by Dockerfile was failing to migrate my current dir into container, as \dt in postgresql container after psql -U django_pass -d django_db {where django_pass is meUserName n django_db is db-Name} further confirmed it - as I was having none of latest models.py’s customuser model as migrated in tables form.
So, I had to make migrations/ folder inside VivekProject2/app , and also create empty _ init _.py. Thanks to one time python manage.py makemigrations, 0001_initial.py was automatica created as-a-result.
But the pity was -
btw, migrations let us reflect changes in models from models.py all the way deep into database table’s schema. done by enter of command: python manage.py makemigrations n migrate {in my case, I am trying to execute my command inside database container - that’s why I couldn’t see all that app.0001_initial, app.0002_initial (migration logs) inside migrations/ folder in app folder}
Btw, a)postgres:15 is docker container
b)Inside this container, I have me-User as django-user out of 100 other users.
c)Under this me-User, I had earlier django_db database which was f**ked up because of inconsistent migration and as in below screenshot, I created afresh virgin postgres database out of 10s-other-can-be-created databases
yes, stackoverflow is still relevant - cause I came to know dropping that database as soln from this- thanx to me googling main error statament, n then I gpt-ed ‘command to drop database’
and now hurray I got below, which is exactly according to what I have in models.py
d) Under this database, I can have 10 other tables like auth_user table etc
So, I once again got InconsistentMigrationHistory problem this time NOT on dockerized-Django but on myLocalMachine’s django.
recommendedReadInNextTab: This blog’s ‘While setting up poetry’ post
Then, rather than DROP DATABASE Agriii n then CREATE DATABASE Agriii, easierWay below:
Then still, python manage.py makemigrations showed no modules named ‘channels’ error. enough w this shit, something must be wrong w packages - so, lets do it NOT w pip coz poetry way is smarter.
So,
as it said to ‘Please change python executable from use env’, I simply chose to do clicking ‘Python’ written lhs of ‘go live’ on bottomestRight corner as below:
n then click obviously .venv Poetry one’s Python n NOT even .venv one’s Python, as venv just cares which Py version, but poetry cares about packaging even sub-dependencies while installing. That’s where .toml comes in picture - toml records all those dependency sub-dependency.
But still,
So, I synced all changes clicking ♻️ on bottomLeft n did:
but still problem, means syncing only didnt work, lets git pull
then, python manage.py makemigrations n python manage.py migrate worked.
now, before I deploy w python manage.py createsuperuser | runserver etc, lemme do below:
to load all those Provinces– Koshi, Bagmati etc etc, District– Chitwan etc etc
Then after, I createsuperuser w sbibek086@g r.T.1! n runserver