Domanda

The Django project I'm working on was set up by someone else, prior to me working on it. It has also the Mezzanine component which I'm not familiar with; have not been needing to use it. Suddenly, I have an error which I can't figure out how to fix...

I have an app 'Dashboards' which started off without any models -- models.py was empty, sans the default from django.db import models. Today, I added a model called Banners into it, and I added the admin.py file (as I was intending to use Django's admin module for it). I may have restarted foreman throughout but I never ran any migrations on the model.

Subsequently, I decided to delete the model definitions as well as admin.py, because I decided to create a separate app to handle the specific feature I was working on. After restarting foreman, Django keeps throwing an error:

ImportError at /
No module named banners.models
Request Method: GET
Request URL:    http://127.0.0.1:9000/
Django Version: 1.5.5
Exception Type: ImportError
Exception Value:    
No module named banners.models
Exception Location: /home/vagrant/www/local/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable:  /home/vagrant/www/bin/uwsgi
Python Version: 2.7.3
Python Path:    
['.',
 '',
 '/home/vagrant/www/src/django-experiments',
 '/home/vagrant/www/src/gargoyle',
 '/home/vagrant/www/src/nexus',
 '/home/vagrant/www/local/lib/python2.7/site-packages/newrelic-2.6.0.5/newrelic/bootstrap',
 '/home/vagrant/www/lib/python2.7',
 '/home/vagrant/www/lib/python2.7/plat-linux2',
 '/home/vagrant/www/lib/python2.7/lib-tk',
 '/home/vagrant/www/lib/python2.7/lib-old',
 '/home/vagrant/www/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/home/vagrant/www/local/lib/python2.7/site-packages']
Server time:    Tue, 18 Feb 2014 01:13:55 +0000

More specifically, in:

./urls.py in <module>
admin.autodiscover() ...
▶ Local vars
/home/vagrant/www/local/lib/python2.7/site-packages/mezzanine/boot/__init__.py in autodiscover
    django_autodiscover(*args, **kwargs) ...
▶ Local vars

I searched all my source, definitely I'm NOT importing 'banners' anywhere. What is the proper way to completely clear it out?

È stato utile?

Soluzione

If you are definitely not importing banners anywhere (a search through your codebase should confirm this), then you may have compiled python files still referencing the old stuff.

I can't reproduce exactly what causes this, but I've run into problems like this many times, specifically manifesting in cryptic urls.py import errors.

Try a good old find . -name "*.pyc" | xargs rm

As usual, be very careful with rm commands - never trust it, triple check you wrote *.pyc or have backups / version control.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top