Importing django reversion gives an error

1.2k views Asked by At

I have the need to add version control for my models in the django admin and for that reason I have installed django-reversion from here.My server does not have have internet connectivity so I could not use pip.I had to manually download the zip file from github,upload it on to my server,extract the contents and run python setup.py install to install reversion.

However,when I try to import it,I get the following error :

root@ns1 /home/project# python
Python 2.7.3 (default, Feb 27 2013, 22:57:49)
[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 6, 0, 'final', 0)

>>> import reversion
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/reversion/__init__.py", line 11, in  <module>
  from reversion.revisions import default_revision_manager, revision_context_manager, VersionAdapter
File "/usr/local/lib/python2.7/site-packages/reversion/revisions.py", line 10, in <module>
  from django.contrib.contenttypes.models import ContentType
File "/usr/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py",  line 1, in <module>
  from django.db import models
File "/usr/local/lib/python2.7/site-packages/django/db/__init__.py", line 83, in <module>
  signals.request_started.connect(reset_queries)
File "/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 88, in connect
  if settings.DEBUG:
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
  self._setup(name)
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in _setup
 % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are    not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
  >>>

As per the github page,the current reversion version is 1.8.0 and should be compatible with django 1.6. What could be the problem ?

1

There are 1 answers

0
MBrizzle On

I know this is an old question, but in case anyone stumbles upon it: The problem here is that you're running the standard python interpreter, rather than the Django shell. You can do import django into a regular python interpreter to check the Django version, but it does NOT set all the various environment variables necessary to run django properly -- including importing django apps. In order to import a django app, you need to instead run the Django shell via

./ python manage.py shell