I have an error while trying to use django-modeltranslation 0.18.3 in Django 2.2.
Here's the end of the traceback:
[...]
from django.db.models.utils import create_namedtuple_class
ImportError: cannot import name 'create_namedtuple_class' from 'django.db.models.utils' (/home/me/project/.venv/lib/python3.10/site-packages/django/db/models/utils.py)
I can't figure what's wrong with modeltranslations and with django. I recreated a clean venv, nothing works.
Their CHANGELOG does not mention it, but they started using some code relative to django >= 3 in v0.18.3. Version 0.18.2 is the last one that supports django 2.2.
Related
I'm using os x , I tried to run the project that I installed from Github
https://github.com/cfpb/idea-box
but there is error says : ImportError: No module named comments
maybe I miss something but since I'm newbie in Django I can't figure it out
Django comments are deprecated in latest version. You can either install older django version (such as 1.5).
Or the better solution is to install comments from external repository like so:
pip install django-contrib-comments
and then change all imports like this:
from django.contrib.comments.models import Comment # old
from django_comments.models import Comment # new
Sources:
Django's docs
Another question
I use django-haystack 2.0.0 to index my site, and it has been working great until I upgraded to Django 1.5 and started using the WSGI interface. If I just use the django_gunicorn command it works great, but the Django documentation "highly recommends" I use the gunicorn command.
When I start my site with the gunicorn command, Haystack throws the following error on any page load:
ImportError: cannot import name signals
I have no problems importing signals from the Django or Python shells. I use virtualenv and install all packages locally inside that environment. My wsgi.py file looks just like the default one in the django admin, except that I add the local path to the python path as such:
path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-2])
if path not in sys.path:
sys.path.append(path)`
Any help you could provide would be very appreciated, thank you!
I don't use gunicorn, but I had the same problem when I used the HAYSTACK_SIGNAL_PROCESSOR setting to point to a custom class that I wrote. That class imported one of my models, which eventually propagated up the import chain, to import my settings module, thus causing a circular import.
When using a setting such as HAYSTACK_SIGNAL_PROCESSOR that points to a class, make sure that class standsalone, and doesn't import either directly or indirectly the Django settings file.
When, from Eclipse, i run my django project, it throws
ImportError django.contrib.messages: No module named messages
Furthermore, in django consolle import django.contrib works fine, it throws
ImportError: No module named messages
Why?
In my django folder, where the python interpreter of pydev points, there is ./contrib/messages folder, so i don't understand why it can't find django.contrib.messages
I have resolved deleting old version of django that was in /usr/lib/pymodules/python2.6/
and reinstalling django.
I'm using django-haystack for searching on my site.
I'm also using django multilingual model for I18n.
I import MultilingualModel in search_indexes.py
I ca run all manangement commands as long as I don't have haystack in the INSTALLED_APPS.
When haystack is in the INSTALLED_APPS and try to run syncdb or migrate (and several other management commands) I'm always getting:
django.core.exceptions.ImproperlyConfigured: ImportError haystack: cannot import name MultilingualModel
This is likely related to the hacks done in haystack.autodiscover(). This behavior is documented here: http://docs.haystacksearch.org/dev/debugging.html#import-errors-on-start-up-mentioning-handle-registrations There is a long discussion in this ticket: https://github.com/toastdriven/django-haystack/issues/84
The long and short if it is that moving haystack.autodiscover() into your urls.py can sometimes resolve this issue. Setting HAYSTACK_ENABLE_REGISTRATIONS = False when running syncdb or migrate has resolved this for me using this snippet in my settings.py:
# FIXME: This is a complete hack to get around circular imports in
# django-haystack and other apps such as django-endless-pagination
SKIP_COMMANDS = ['syncdb', 'migrate', 'schemamigration', 'datamigration']
if any([command in sys.argv for command in SKIP_COMMANDS]):
HAYSTACK_ENABLE_REGISTRATIONS = False
search_indexes.py doesn't get processed unless haystack is in INSTALLED_APPS. The problem is with the import of MultilingualModel in general. Either it's not truly installed in your environment (attempt to import it from a vanilla python shell), or you have the import wrong (it's actually in another module, for example).
Once you can successfully import MultilingualModel from a python shell, you won't have any problems.
http://pastebin.com/umBiCJvp here's the traceback and settings. I'm using Django version 1.2.3.
Are you sure that you are running Django 1.2.3. This error message is common when changing to Django 1.2 from 1.1 (since the way database settings are defined has changed).
You can check your version of Django by running python manage.py shell and then:
import django
print django.VERSION
That should give you (1,2,3,'final',0) or something similar. If it's not 1.2.x then thats your problem.