So I ran my program based on from here and It worked without any error. I go to to /admin. I login. So far everything is good. Then when it loads I get this:
I checked the traceback (which is really long) and none of includes my code. It doesn't tell me what part of the code this error is occurring in so I don't know how to approach this. Please explain what this is, why this is happening, and how I can fix it.
If you need any part of my code, just ask in comments because I don't know where this is happening.
You need to run migrate command in-order to force django to create auth tables.
python manage.py migrate
Then for any change you made on models, don't forget to run these two commands.
python manage.py makemigrations
python manage.py migrate
Use pip install django==2.1.5
If the problem persists,
Use python manage.py migrate --run-syncdb
by default, the auth table is not created in the database
so first we need to create the table and reload the page
to achieve the same
make the migrations by typing the following command
1. python3 manage.py makemigrations
2. python3 manage.py migrate
Till the time they don't debug this issue with Django and Sqlite3 use the older versions of Django
You may consider using version 1.10.5(using command pip install --upgrade django==1.10.5)
yes, that was fault of django version ,when i installed django==2.1.5 that problem was solved.
Install latest django version
$ pip3 install django==2.2.8
$ python3 manage.py makemigrations
$ python manage.py migrate
then reload page in browser
this is the problem with migration just type the following command:-
python manage.py migrate
If you still get error after you lunched
python manage.py migrate
and for every change you made on models
python manage.py makemigrations
python manage.py migrate
Then check if you have Django version older than 2.1.5, because this latter version fixes a bug returning "OperationalError>no such table" when adding an object to your database as superuser.
So try to
pip install Django==2.1.5
However, you will have to re-write your project anew.
user permission
Hi
In Django Administration :check if the user has the right permission, it should work
use these commands
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver
Related
I am using Pycharm for django development, after adding some models to the models.py the terminal is stuck at python manage.py makemigrations command, runserver doesn't work also.
The terminal is freezing.
It was working perfectly, it did not work after the modification in models.py, I tried to delete the migration files but it didn't work, restart the computer didn't help.
Look at the pictures please.
Any ideas?
Thanks a lot
makemigrations
runserver
The same situation happened to me and I looked deeper at the models I had changed.
I just commented the fields i didn't want anymore, not removed, that was the problem. Try removing.
Maybe the command "python manage.py makemigrations" already ran and you just need to do a "python manage.py migrate".
I've got a Django application which has been happily humming along now for quite some time (2 years or so).
It's on 3.0.10 currently - when I tried to upgrade to 3.1.3, it says there was a migration for the auth application. No worries! Never been an issue before...
I ran python manage.py migrate and got the following error:
"Cannot find the object "auth_user" because it does not exist or you do not have permissions."
Which, I suppose would be true because we do not have a User model at all in this application. There is no auth_user table, that is correct. In other apps we have an AbstractUser that routes to a table named: org_user - but again:
this particular app (and project) do not have any User model associated with them
Obviously this (apparently, now) leads to some issues.
Any thoughts on how to get around this? I thought about removing auth from installed apps and tried that but it led to more issues when trying to runserver.
You can fake a migration using --fake option:
python manage.py migrate --fake auth
python manage.py migrate
But I suspect the error you get could be symptomatic of a project design issue, such as not setting properly settings.AUTH_USER_MODEL
Solution 1 :- Run these commands :-
python manage.py migrate auth
python manage.py migrate
Solution 2 :- Try to copy your Project in another folder and then run migrations.
After I installed django i wrote the start project command to verify django is working or not.
i.e,
django-admin startproject mysite
cd mysite
python manage.py runserver
After that I got an IP address(http://127.0.0.1:8000/)
but when i link to this http://127.0.0.1:8000/, it is showing unable to connect. what should i do now?
Don't worry this is not a big issue!
As per your comment mentioned above, Run the python manage.py runserver then go to new instance of powershell and do other stuff what you want to try.
Let that runserver window isolated.
I'm in production and just ran syncdb but I made a mistake and want to delete what syncdb did, including all data in the tables is fine. Just a fresh start in the databases so I can run syncdb again.
(virtualenv-2.7)[root#server mysite]# python manage.py sqlclear mainapp | python manage.py dbshell
CommandError: One or more models did not validate:
app.comment: 'poster' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
app.myuser: The field named as the USERNAME_FIELD should not be included in REQUIRED_FIELDS on a swappable User model.
Recreate database is probably the best way. Also you can do it using reset_db management command from django-extensions package.
The Django 1.7 support migrate
you just run python manage.py migrate again after edit.
more features to see: release note
As J0HN stated in the comments, the best thing to do to start fresh was to actually just delete the database. I thought it might mess something up, but it won't. Simply login to mysql.
drop database whatever_your_database_name;
create databse whatever_your_database_name;
Then simply sync it again with python manage.py syncdb
Maybe its lazy, but I run:
django-admin.py reset_db --router=default --noinput
Hey guys,
Im trying to migrate django-cms from version 2.1.0 beta3 to 2.1.3 (stable), i have read many posts that recommend South for this, unfortunately i have never done anything with south, and i didn't have it installed when creating my projects, so i have followed many solutions that include running:
python manage.py migrate --fake
on the old version and then installing the new version and run:
python manage.py migrate
however this does not work, because django throws the following error:
no such column: cms_page.limit_visibility_in_menu
so i was wondering if anyone has another solution they would like to share.
btw im using python 2.7 and Django 1.2.1
I use this sequence when db changes and we need to do schemamigration using South:
./manage.py schemamigration your_app_name --auto
Note, than database should fit your models, otherwise you'll get errors.
Then, after you get success message and invitation to migration, you do:
./manage.py migrate
That's it. Backup you database before, so you can rewind. Then you just will need to restore your dumped database and delete failed migration file from migrations directory.