I know there are many questions about this problem, I looked through the solutions and unfortunately none of them worked for me.
I created a new app called "usermanagement", and added a model to the app. After adding the model I added usermanagement to INSTALLED_APPS in settings. Then I ran python manage.py makemigrations, and python manage.py migrate. This all worked fine! I also did try running the migrations with the app-name.
The problems start when I try to add a new instance of the model to the database in the Python-Django shell, by using:
>>>a = ClubOfficial(name="randomName", email="[email protected]")
>>>a.save()
I get the following error:
django.db.utils.ProgrammingError: relation "usermanagement_clubofficial" does not exist LINE 1: INSERT INTO "usermanagement_clubofficial" ("name", "email") ...
Below is the model code:
class ClubOfficial(models.Model):
name = models.CharField(max_length=254)
email = models.EmailField(max_length=254)
If it helps, I use postgresql, and have tried restarting the server. The other apps in the program also work perfectly fine, it is just usermanagemenet that has this problem.
Does anyone know what could be going wrong?
Thank you for your time!
Note: I created a new app now with a different name, copy-pasted things from usermanagement and everything worked fine. I think the problem might be that before there was an app named usermanagement which was deleted, before I created it again. Maybe that messed up the database somehow.
makemigrations
with the app name ? – PRMoureuClubOfficial
is stored in which file ? – PRMoureu0001_initial
, do you see the modelClubOfficial
? – PRMoureupython manage.py showmigrations
? is there a tick before 0001_initial of your app? – Jahongir Rahmonov