Forums

no such table: auth_user

I installed a virtualenv, then django. I checked in the MySQL database, and all the auth_user etc.. tables are setup properly. makemigrations, migrate worked properly as expected. After logging into admin area I get the

OperationalError at /admin/login/ no such table: auth_user

Any thoughts?

Hmm. maybe you need to do a create super user?

I did that already.

double check that you are using the correct database settings? django defaults to on-disk sqlite I believe.

One common problem if you're using SQLite is which directory your database is stored in. If you specify the SQLite file with just a filename, no directory -- like "database.db" rather than "/home/lgs/something/database.db" -- then Django will open a database file in whatever working directory it happens to be in when the code is run.

If you do a manage.py migrate in a bash console, then the working directory will be the one where you ran the command from.

But when your web app is running, it may be using a different working directory.

To make sure they're the same, you can either specify a full path including directory in your settings.py, or you can specify an explicit working directory for the web app on the "Web" tab.

I was using MySql. Django was able to interact with the DB (as it did create the tables), just for some reason afterwards it couldn't see what it wrote. I reinstalled my virtualenv, and reinstalled django and it worked :-).

ok, well, glad it's working now in any case!

My problem was that it was using the wrong db file, so i went to the settings.py file and hardcoded the path to the one in my project

I am using mysql,I create the superuser and everything is fine, when I access a route /mysite/admin/ I access correctly with my username and password then it gives me the error "no table: author_user". Looking at the files, I see that django created a db.sqlite3 in the root .... ...?

How are you specifying the path to the SQLite database in your Django settings file?

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'Mandinga$data', 'USER': 'Mandinga', 'PASSWORD': 'xxxx', 'HOST': 'Mandinga.mysql.pythonanywhere-services.com', 'PORT': 3306, } }

Can we take a look at your files and data? We can see them from our admin interface, but we always ask for permission first.

It is already working properly. I uninstalled the app and went back to upload it and it worked. Thank you

OK -- glad you got it working!

I am having a similar issue. I cloned my project from github and it is giving off this error OperationalError at /admin/login/ no such table: account_account

can anyone be of help thanks

Have you run migrations?

I changed the database name to absolute path like this '/home/omeco4christ/zingerweb/src/db.sqlite3' and ran migrations and it worked. Thanks so much

yayy!

I am getting same error please help

@Keran17 Have you run migrations?

yes I have

Have you run them with the same settings your deployed web app is using?

yes

Can you look into my files and data to check the issue because it's being difficult for me to resolve it.

I can see that your SQLite database is empty; could you tell us the exact command that you run to do the migrations?

[formatted by admin]

python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

What was the output of that commands? (Just to be sure -- did you run that having your virtual env activated)?

yes with the help of dj4e tutorials I have run all the commands in sequence

What was the output of the commands?

the same as shown in tutorials I didn't have screenshots of them but I am sure they were same as in tutorial.

Are you using a virtual environment? What database do you use?

I am using sqllite3 on pythonanywhere

If you're still having this issue, could you run commands mentioned above, and paste their output here?

Superuser created successfully. 10:43 ~/mysite $ python manage.py runserver Performing system checks... System check identified no issues (0 silenced). April 25, 2021 - 10:43:24 Django version 1.11.26, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Error: That port is already in use.

You cannot run the Django development server in a console. Create a web app to run your Django project. There are a number of articles on our help pages to get you started.

10:44 ~/mysite $ python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, polls, sessions Running migrations: No migrations to apply. 10:53 ~/mysite $ python manage.py makemigrations No changes detected 10:53 ~/mysite $ python manage.py createsuperuser Username: dj4e Email address: kerangupta178@gmail.com Password: Password (again): Superuser created successfully. 10:54 ~/mysite $ python manage.py runserver Performing system checks... System check identified no issues (0 silenced). April 25, 2021 - 10:55:00 Django version 1.11.26, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Error: That port is already in use. 10:55 ~/mysite $ ^C 10:55 ~/mysite $ python manage.py runserver Performing system checks... System check identified no issues (0 silenced). April 25, 2021 - 10:55:20 Django version 1.11.26, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.

Are you looking for some help related to the above output? Do you have a question about it? Except for your attempt at running the Django dev server at the end, it looks like everything worked fine.

Hello,

I have been trying to login into my site, but I get this error:

OperationalError at /account/login/
no such table: account_userbase
/home/equant/.virtualenvs/mysite-virtualenv/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py,     line 413, in execute

Weirdly enough, when I run my project in my own computer (localhost), I can login without worries at all. Also, when I uploaded my project to GitHub (before cloning to PythonAnywhere), my database had 2 users. Is that a problem? Whenever I try to login using their credentials, I get this error message. I also did the following steps to solve it:

1) ./manage.py makemigrations and then ./manage.py migrate (with my venv activated and in the BASE_DIR): Result: "No migrations to apply."

2) Also tried to a create superuser (remember: I already had one though). It lets me enter my username, but, as soon as I enter it, I get: Result: django.db.utils.OperationalError: no such table: account_userbase What a nice result isn't it?

My guess was that something was wrong with the directories. Then, I changed settings.py's DATABASES to this: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': '/home/equant/file1/file2/db.sqlite3', } } In other words, I described the entire path. But nothing changes, even if I do 1 or 2. I also reloaded the web app.

Right now, I have no ideas what to do. As you all can see, I'm using sqlite database and did not set up any other databases, such as MySQL. What should I do?

Thanks

Did you upload your local db to PythonAnywhere? Maybe try to create a new db on PA. Also -- do you commit migrations (meaning: do you keep them in sync between your local environment and PA?). The error suggests that there've been some changes to the model account_userbase which are not reflected in the db.

Yes, I did upload it.I did again all the process of deploying the project on GitHub then here on PA, with a freshly new database. The same problem occurred. Right now, I have just deleted it and then created a new one via console's bash. But, again, the same problem occurred.

It comes to my attention that these problems do not happen when I'm running on my own PC. Surely, the codes are identical, in other words, I did not change a thing on the models.

How do account app migrations look like? (Reach us on support@pythonanywhere.com if you do not want to share to many details on public forums)

Hello, I am using mysql. When I do: python manage.py makemigrations

I get:

django.db.utils.ProgrammingError: (1146, "Table 'ITnews$default.auth_user' doesn't exist")

It is my database settings in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'ITnews$default',
        'USER': 'ITnews',
        'PASSWORD': 'mypass',
        'HOST': 'ITnews.mysql.pythonanywhere-services.com',
    }
}

Did you run python manage.py migrate?

class CustomUser(AbstractUser):

user_type_data = ((0, "Staff"),(1, "SuperAdmin"), (2, "StateAdmin"), (3, "LabTechnician"),(4, "HealthWorker"))
role_id = models.CharField(max_length=10, blank=True, null=True)

bash

10:10 ~/soul $ python manage.py migrate
SystemCheckError: System check identified some issues:
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'auth.User.groups' clashes with reverse accessor for 'employee.CustomUser.groups'.
        HINT: Add or change a related_name argument to the definition for 'auth.User.groups' or 'employee.CustomUser.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'auth.User.user_permissions' clashes with reverse accessor for 'employee.CustomUser.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'auth.User.user_permissions' or 'employee.CustomUser.user_permissions'.
employee.CustomUser.groups: (fields.E304) Reverse accessor for 'employee.CustomUser.groups' clashes with reverse accessor for 'auth.User.groups'.
        HINT: Add or change a related_name argument to the definition for 'employee.CustomUser.groups' or 'auth.User.groups'.
employee.CustomUser.user_permissions: (fields.E304) Reverse accessor for 'employee.CustomUser.user_permissions' clashes with reverse accessor for 'auth.User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'employee.CustomUser.user_permissions' or 'auth.User.user_permissions'.

[edit by admin: formatting]

That looks like you have issues in the models that you have defined, so you'll have to fix those.

What issue in my model, i have customizing the auth_user Overriding the Default Django Auth User and adding One More Field (user_type) class CustomUser(AbstractUser):

pls let me know where i am wrong

https://stackoverflow.com/questions/22538563/django-reverse-accessors-for-foreign-keys-clashing