16

I am working with eav-django(entity-attribute-value) in django 1.9. Whenever I was executing the command ./manage.py runserver , I got the error :

Unhandled exception in thread started by <function wrapper at 0x10385b500>
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/shakil_grofers/src/django-eav/eav/models.py", line 42, in <module>
    from django.contrib.contenttypes import generic

I tried to import generic by adding:

from django.contrib.contenttypes import generic 

in models.py. Then after few research I found out that generic has been deprecated in Django 1.7 and is no more in Django 1.9. Can anyone tell me in which other library this functionality has been added in Django 1.9 and how to use it?

Idos
  • 15,053
  • 14
  • 60
  • 75

3 Answers3

23

The django.contrib.contenttypes module has been reorganized in Django 1.7.

Instead of django.contrib.contenttypes.generic.GenericForeignKey you can now use django.contrib.contenttypes.fields.GenericForeignKey. See the sample code in the documentation:

https://docs.djangoproject.com/en/1.7/ref/contrib/contenttypes/#generic-relations

Selcuk
  • 57,004
  • 12
  • 102
  • 110
  • can you suggest how to use eav-django with this?? –  Feb 17 '16 at 10:42
  • You need to modify the `django-eav` source code and replace all the `generic.GenericForeignKey`s with `fields.GenericForeignKey`. You can also make a pull request to the repository while you are at it :) https://github.com/mvpdev/django-eav/ – Selcuk Feb 17 '16 at 10:44
  • In my case, my project uses python 3 and I forgot to enable the virtual env. So the standard python (2.7) was giving this error. I was stupid! – Eduardo May 30 '18 at 17:51
1

This functionality has been moved into the .models and .fields modules. It's just the specific file that is removed; the generic relations functionality still exists, just split into separate files.

the_unknown_spirit
  • 2,518
  • 7
  • 34
  • 56
1

Update Django.tagging package from Python's official site, not from Pip source, because Pip does not have the latest version.

Neo
  • 11
  • 1