Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: type object 'MyMetadata' has no attribute '_meta' #58

Open
wangyc666666 opened this issue Oct 15, 2016 · 0 comments
Open

Comments

@wangyc666666
Copy link

wangyc666666 commented Oct 15, 2016

mmand_line
utility.execute()
File "/usr/local/python3.4/lib/python3.3/site-packages/Django-1.8.11-py3.3.egg/django/core/management/init.py", line 328, in execute
django.setup()
File "/usr/local/python3.4/lib/python3.3/site-packages/Django-1.8.11-py3.3.egg/django/init.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/python3.4/lib/python3.3/site-packages/Django-1.8.11-py3.3.egg/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/usr/local/python3.4/lib/python3.3/site-packages/Django-1.8.11-py3.3.egg/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/usr/local/python3.4/lib/python3.3/site-packages/Django-1.8.11-py3.3.egg/django/contrib/admin/init.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/usr/local/python3.4/lib/python3.3/site-packages/Django-1.8.11-py3.3.egg/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/local/python3.4/lib/python3.3/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1584, in _gcd_import
File "", line 1565, in _find_and_load
File "", line 1532, in _find_and_load_unlocked
File "", line 584, in _check_name_wrapper
File "", line 1022, in load_module
File "", line 1003, in load_module
File "", line 560, in module_for_loader_wrapper
File "", line 868, in _load_module
File "", line 313, in _call_with_frames_removed
File "/var/www/html/chouti/app01/admin.py", line 10, in
register_seo_admin(admin.site, MyMetadata)
File "/usr/local/python3.4/lib/python3.3/site-packages/rollyourown/seo/admin.py", line 52, in register_seo_admin
if metadata_class._meta.use_sites:
AttributeError: type object 'MyMetadata' has no attribute '_meta'

vim /usr/local/python3.4/lib/python3.3/site-packages/rollyourown/seo/admin.py

def register_seo_admin(admin_site, metadata_class):
if metadata_class._meta.use_sites:
path_admin = SitePathMetadataAdmin
model_instance_admin = SiteModelInstanceMetadataAdmin
model_admin = SiteModelMetadataAdmin
view_admin = SiteViewMetadataAdmin
else:
path_admin = PathMetadataAdmin
model_instance_admin = ModelInstanceMetadataAdmin
model_admin = ModelMetadataAdmin
view_admin = ViewMetadataAdmin

vim app01/models.py
from rollyourown import seo

class MyMetadata(seo.Metadata):
title = seo.Tag(head=True, max_length=68)
description = seo.MetaTag(max_length=155)
keywords = seo.KeywordTag()
heading = seo.Tag(name="h1")
vim /var/www/html/chouti/app01/admin.py

ecoding:utf-8

from django.contrib import admin
from app01 import models
from app01.models import MyMetadata
from django.db.models.lookups import Search
from rollyourown.seo.admin import register_seo_admin
from django.contrib import admin

from app01.seo import MyMetadata

register_seo_admin(admin.site, MyMetadata)

Register your models here.

class News(admin.ModelAdmin):
list_display=('title','summary','url','favor_count','reply_count','news_type','user','create_date')
list_filter=('create_date',)
search_fields =('title','user')

admin.site.register(models.News,News)
admin.site.register(models.UserType)
admin.site.register(models.Admin)
admin.site.register(models.NewType)
admin.site.register(models.Reply)
admin.site.register(models.Category)
~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant