Python manage.py makemigrations says no changes detected


#1

In the section “Finishing setting up your database with migrations,” the shell command “python manage.py makemigrations” produces “No changes detected”

I keep forgetting to work inside of my venv, so maybe something did not get saved properly in a previous step?

Update: In the very next section, you ask us to open admin.py, and apparently that files does not exist in my collections folder. I did the createsuperuser thing again, but that didn’t help.


#2

Can you list out all the files in your folders, in a format like this?

hellowebapp (your project name)
— collection (your app name)
—— models.py
—— (etc.)
— hellowebapp (your project name)
—— settings.py
—— (etc.)


#3

home
—.cache/
—.git/
—.iPython/
—.virtualenvs/
—Dropbox
—speclist01/
——collection/
———pycache/
———static/
————css/
————images/
————js/
———templates/
————layouts/
—————base.html
————about.html
————contact.html
————index.html
———init.py
———init.pyc
———models.py
———models.pyc
———tests.py
———views.py
——django18/
——media/
——speclist01/
———init.py
———init.pyc
———settings.py
———settings.pyc
———urls.py
———wsgi.py
——static/
——db.sqlite3
——django-admin.py
——manage.py
—.bashrc
—.gitconfig
—.profile
—.pythonstartup.py
—.viminfo
—.vimrc
— README.txt

I thought you probably wouldn’t care to see inside some of the folders like “cache” so they are not expanded. Thanks!


#4

As far as I can tell, you have a few layers of folders/nesting than you should, and Django might not be able to see your database. Generally there should be the top level folder (with manage.py), then your app folder (collection, with models.py.) There is a folder called speclist101 in between, so looks like the project was set up differently than what was recommended in Hello Web App. :( Did you do anything extra?


#5

In one of your supplementary instruction pages, (https://github.com/hellowebapp/hellowebapp/blob/master/installation-instructions/starting-your-project.md) you list a folder tree that shows:

hellowebapp/
-manage.py
-hellowebapp/
init.py
–settings.py
–urls.py
–wsgi.py

It appears to be the same nesting structure to me.


#6

Oh I see, you went from big to little dashes halfway through.

What’s in your models.py? Can you paste it into pastebin?


#7

Yes, that was rather confusing. I have fixed the hyphenation, but upon further inspection, it does appear that manage.py is in a different folder than you had it. The guys at PythonAnywhere said this shouldn’t matter (it’s their default when you launch a Django app there), but they said maybe Django1.8 isn’t playing nice, so I am going to try with 1.7.8.

In case you want to see models.py:
http://pastebin.com/UfX3s094


#8

Ok, I have solved this problem. I started from scratch with a new environment, and this time with Python3.4 and Django1.7.8, I am able to get past makemigrations. Yay! There were a few settings with PythonAnywhere which I took more time to figure out this go around, so I can’t say with certainty if makemigrations was broken in Django1.8, but it may be something to keep an eye on.


#9

Thanks! I definitely need to try working with Python Anywhere. Glad it worked out for you and thanks for letting me know the process you took to fix it. :) :) :)


#10

hello,
I had a similar issue (the same warning message in the CLI)
Im my case the issue was that my app folder was named ‘collection’, while in settings.py it was ‘collections’ (with ‘s’ in the end)
once I corrected the app name in the settings.py file, it went OK.


#11

Thanks, good to know!


#12

Hi! thank you for the forum, it does help. Ok so I have the same problem as mentioned above… Pg37

$ python manage.py makemigrations

The last 3 lines after “No chages detected” were accidental key presses.

Also see that a “migrations” folder is inside the collection folder I am not sure if this folder existed before executing “$ python manage.py makemigrations”

Also this is how it looks inside settings.py

Application definition

INSTALLED_APPS = [
‘collection’, #this is the app we added
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘django.contrib.humanize’, #This app was added as requested from page 30
]

These are my folders:

myhellowebapp

collection

migrations

init.py, init.pyc

static

css

style.css

images
js

templates

layouts

base.html

about.html, contact.html, index.html

admin.py, admin.pyc, apps.py, init.py, init.pyc, models.py, models.pyc, tests.py, views.py, views.pyc

hellowebapp

init.py, init.pyc, settings.py, settings.pyc, urls.py, urls.pyc, wsgi.py, wsgi.pyc

venv

bin

(etc)

include

(etc)

lib

(etc)


#13

Ok so I fixed it, it was my mistake. I never edited models.py to add

class Thing(models.Model):
name = models.CharField(max_length=255)
description = models.TextField()
slug = models.SlugField(unique=True)

So obviously there was no changes detected lol.

The one thing that worries me for future use is in the picture posted above where it says “…and will be removed in Django 1.10(got collection.views.index) Pass the callable instead…” what does that mean? and how it may affect me later i don’t know

Thanks


#14

Here’s a Stack Overflow about that error message: https://stackoverflow.com/questions/34096424/django-support-for-string-view-arguments-to-url-is-deprecated-and-will-be-rem

What’s your urls.py look like?


#15

Hi, sorry I didn’t get back as quick, but here is my urls and settings. Before looking through the code please note that the urls I have does not import include nor patterns because it just did not come like that when I installed python or django. Idk but it just didnt. I never wanted to mess with that code and it did not make a difference so far.

  1. This did not make a difference because it seemed everything was working properly in the urlpatterns [] list in my code. In the book urlpatterns = a function named patterns( ) and that is why it seems it needs to import include. (I guess)

  2. I didn’t need include until chapter 10 page 65 when the book requires it for
    """ url(r’^accounts/’, include( ‘registration.backends.simple.urls’ )) “”"

I don’t know what the function include does and why my code did not need it then and why it needs it know

Also know that I installed with “”“pip install django-registration-redux==1.1"”"" while in the venv inside
projects/myhellowebapp.

And thank you beforehand

#the book in page 24 has include and patterns for importing

from django.conf.urls import url #this is how i got it from the begining
from django.contrib import admin
from django.views.generic import TemplateView

urlpatterns = [
url(r’^$’, ‘collection.views.index’, name=‘home’),

url(r'^about/$',
    TemplateView.as_view(template_name='about.html'),
    name='about'),

url(r'^contact/$',
    TemplateView.as_view(template_name='contact.html'),
    name='contact'),

url(r'^things/(?P<slug>[-\w]+)/$',
   'collection.views.thing_detail',
   name='thing_detail'),

url(r'^things/(?P<slug>[-\w]+)/edit/$',
    'collection.views.edit_thing', name='edit_thing'),

#in the book page 65 indicates to write the following:
url(r'^accounts/', include('registration.backends.simple.urls')),

#The following line is how it started without any changes but the book shows it in a different way

url(r’^admin/’, admin.site.urls),#in the book this shows “, include(admin.site.urls)”

#the book shows:
url(r’^admin/’, include( admin.site.urls)),
]

import os

INSTALLED_APPS = [
‘collection’, #this is the app we added
’django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘django.contrib.humanize’,
‘registration’, #Page 64 MyHelloWebApp
]

#This is the error Im having in the terminal

(venv) renato@renato-Lenovo-G50-70:~/projects/myhellowebapp$ python manage.py runserver

Unhandled exception in thread started by <function wrapper at 0x7f3aec0d6b90>

Traceback (most recent call last):
File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py”, line 226, in wrapper
fn(*args, **kwargs)

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py”, line 109, in inner_run
autoreload.raise_last_exception()

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py”, line 249, in raise_last_exception
six.reraise(*_exception)

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py”, line 226, in wrapper
fn(*args, **kwargs)

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/init.py”, line 18, in setup
apps.populate(settings.INSTALLED_APPS)

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/apps/registry.py”, line 115, in populate
app_config.ready()

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/contrib/admin/apps.py”, line 22, in ready
self.module.autodiscover()

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/contrib/admin/init.py”, line 26, in autodiscover
autodiscover_modules(‘admin’, register_to=site)

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/utils/module_loading.py”, line 50, in autodiscover_modules
import_module(’%s.%s’ % (app_config.name, module_to_search))

File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/registration/admin.py”, line 2, in
from django.contrib.sites.models import RequestSite

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/contrib/sites/models.py”, line 83, in
class Site(models.Model):

File “/home/renato/projects/myhellowebapp/venv/local/lib/python2.7/site-packages/django/db/models/base.py”, line 102, in new
"INSTALLED_APPS." % (module, name)

RuntimeError: Model class django.contrib.sites.models.Site doesn’t declare an explicit app_label and isn’t in an application in INSTALLED_APPS.


#16

Also I looked through the files and django and registration have the same folder level inside site-packages so without using “”“include”"" or importing “”“site-packages”"" should the compiler know what I am referring to when i say “”“url(r’^accounts/’, registration.backends.simple.urls)”"" ???


#17

Fixed so far

INSTALLED_APPS = [
‘collection’, #this is the app we added
’django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘django.contrib.sites’,#this was not in the initial code but I had to add it as recommendation in http://django-registration-redux-referrals.readthedocs.io/en/stable/quickstart.html
’django.contrib.humanize’, #This app was added as requested from page 30
’registration’, #Page 64 MyHelloWebApp, registration needs django.contrib.sites to work

This will throw an import error with RequestSite
RequestSite is now in another location

TO SUMMARIZE:

add django.contrib.sites to your applications once you run your server in the terminal you probably will get the import error, that is because RequestSite is in another location so just check the link given and try it again.


#18

FYI, I borked my email server and didn’t notice, and ergo missed these updates. Just wanted to apologize, sorry about that!


#19

A similar thing happened to me and it was because I was missing the migrations folder with it’s init file:

├── my_app
│ ├── admin.py
│ ├── admin.pyc
│ ├── apps.py
│ ├── init.py
│ ├── migrations
│ │ ├── init.py
│ ├── models.py
│ ├── tests.py
├── manage.py

Hope it helps!