database tables are not being created

61 views
Skip to first unread message

jjander...@gmail.com

unread,
Aug 7, 2017, 7:33:18 PM8/7/17
to Django users

I have been working on a django application for several months, learning as I go. I have run into a problem now and I'm not sure what I should be doing next.

Up until now my admin has worked, but I had a problem and a colleague told me he was pretty sure it was a pycharm bug. He suggested that I remove the database (db.sqlite3). I did that and I also removed all of the existing migration files in my development area.

When I run 'python manage.py makemigrations', I now get the followoing output:

/home/jja/.virtualenvs/PivotalBase-2017.6.16/bin/python /home/jja/prog/newSiggy/manage.py makemigrations
setting.py: BASE_DIR =  /home/jja/prog/newSiggy
FINISHED settings.py
No changes detected

Process finished with exit code 0

Then I run 'python manage.py migrate' and my output is:

/home/jja/.virtualenvs/PivotalBase-2017.6.16/bin/python /home/jja/prog/newSiggy/manage.py migrate
setting.py: BASE_DIR =  /home/jja/prog/newSiggy
FINISHED settings.py
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions, sites
Running migrations:
  No migrations to apply.

Process finished with exit code 0


I'm not sure what to do next. My models are in place, my 2 admin directories are in place. I have created an 'xxx_admin' file for each model and I have registered the admin classes. After running 'makemigrations' and 'migrate', a db.sqlite3 file exists, but only the django tables are to be found, not the tables for my models. I'm going through the documentation to try to figure out if I have missed a step in the process, but so far I have not found anything.

Any suggestions?

Jim A.

Andréas Kühne

unread,
Aug 7, 2017, 7:54:43 PM8/7/17
to django...@googlegroups.com
Have you added the application your models belong to to the INSTALLED_APPS part of settings.py? And have you added the models file in that application?

Regards,

Andréas

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ba1d7f25-f83b-4f74-99a3-7992c29b6f2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jjander...@gmail.com

unread,
Aug 7, 2017, 8:09:40 PM8/7/17
to Django users

Andreas,

The apps are included in the INSTALL_APPS in settings.py

With regard to the models file, I'm not sure what you are referring to. In my application there is a driectory 'models' and in that directory, there is a separate file for each model and inside each of those files there is a class for the model that is indirectly derived from models.Model.

Jim

Andréas Kühne

unread,
Aug 7, 2017, 8:16:40 PM8/7/17
to django...@googlegroups.com
Ok,

Regarding point 2 there - have you added the models to the __init__.py file? Imported them as in:

from .model1 import Model1

As far as I have seen, this is needed to make sure the migrations can detect the models.

Regards,

Andréas

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Vijay Khemlani

unread,
Aug 8, 2017, 1:34:37 AM8/8/17
to django...@googlegroups.com
As far as I know you also need to declare the app_label for each model

class Meta:
    app_label = 'your_app_name_here'

jjander...@gmail.com

unread,
Aug 9, 2017, 10:13:37 PM8/9/17
to Django users

Andreas,

Thank you for the help. It turned out my __init__.py file was missing in my migration directories. Once added, everything ran great.


Jim

On Monday, August 7, 2017 at 3:33:18 PM UTC-4, jjander...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages