I’m trying to add django-seo into my site. But I can’t cope with setting up. I followed instructions documentation, but error occurs.
This is what I did:
- Installed django-seo packacge
- Added rollyourown.seo to INSTALED_APPS
- Created seo.py file in my site content app
And this is what I wrote into seo.py file:
from rollyourown import seo
class Metadata(seo.Metadata):
title = seo.Tag(head=True, max_length=68)
description = seo.MetaTag(max_length=155)
keywords = seo.KeywordTag()
heading = seo.Tag(name="h1")
class Meta:
seo_views = ('SiteContent',)
seo_models = ('SiteContent',)
When Meta class is removed, I can’t add any meta tags to contnet via Django Admin Site( I registered it in admin site ). I’ve read that django-seo use get_absolute_url() to deal with it. But in my site app I don’t use this function for provide more some utilities to multilanguage.
But if i add Meta class, i will get this error:
Traceback (most recent call last):
File "F:/Site/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "F:Python27libsite-packagesdjangocoremanagement__init__.py", line 385, in execute_from_command_line
utility.execute()
File "F:Python27libsite-packagesdjangocoremanagement__init__.py", line 354, in execute
django.setup()
File "F:Python27libsite-packagesdjango__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "F:Python27libsite-packagesdjangoappsregistry.py", line 108, in populate
app_config.import_models(all_models)
File "F:Python27libsite-packagesdjangoappsconfig.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "F:Python27libimportlib__init__.py", line 37, in import_module
__import__(name)
File "F:Python27libsite-packagesdjangoseo-1.0-py2.7.eggrollyourownseomodels.py", line 10, in <module>
__import__(module_name)
File "F:SiteSiteContentseo.py", line 5, in <module>
class Metadata(seo.Metadata):
File "F:Python27libsite-packagesdjangoseo-1.0-py2.7.eggrollyourownseobase.py", line 166, in __new__
options = Options(Meta, help_text)
File "F:Python27libsite-packagesdjangoseo-1.0-py2.7.eggrollyourownseooptions.py", line 19, in __init__
self._set_seo_models(meta.pop('seo_models', []))
File "F:Python27libsite-packagesdjangoseo-1.0-py2.7.eggrollyourownseooptions.py", line 96, in _set_seo_models
seo_models.extend(models.get_models(app))
File "F:Python27libsite-packagesdjangodbmodels__init__.py", line 54, in alias
return getattr(loading, function_name)(*args, **kwargs)
File "F:Python27libsite-packagesdjangoutilslru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "F:Python27libsite-packagesdjangoappsregistry.py", line 168, in get_models
self.check_models_ready()
File "F:Python27libsite-packagesdjangoappsregistry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
I tried diffrent solutions but nothing helped.
3
Answers
Django-SEO is not compatible with Django 1.7, which is the first version of Django that includes the
AppRegistry
.Either rollback to Django 1.6.x or remove Django-SEO.
I got it working by changing get_query_set() to get_queryset()(changed in django1.8) in file rollyourownseobackends.py
As original Django-SEO is not supported anymore, these guys made and support their own version / fork of Django-SEO. I use it with Django 1.8.8, Python 3 is supported too.
https://github.com/whyflyru/django-seo