I followed the instruction found here
http://django-blog-zinnia.readthedocs.org/en/latest/how-to/extending_entry_model.html
Unfortunately I am having trouble extending. First strange thing is that - I have to change the way the entry modules are imported:
from
from zinnia.models.entry import Entry
from zinnia.admin.entry import EntryAdmin
to
from zinnia.models import Entry
from zinnia.admin import EntryAdmin
After changing, I then ran the server and went to the admin page but then I got this error.
'RatingAdmin.fieldsets[0][1]['fields']' refers to field 'rating' that is missing from the form.
This is my code admin.py
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from zinnia.models import Entry
from zinnia.admin import EntryAdmin
class RatingAdmin(EntryAdmin):
# into the 'Content' fieldset
fieldsets = ((_('Content'), {'fields': (
'title', 'content', 'image', 'status', 'rating')}),) + \
EntryAdmin.fieldsets[1:]
# Unregister the default EntryAdmin
# then register the EntryGalleryAdmin class
admin.site.unregister(Entry)
admin.site.register(Entry, RatingAdmin)
Here is my Abstract class model happy_models.py
from django.db import models
from zinnia.models.entry import EntryAbstractClass
class Happy(models.Model):
rating = models.CharField(max_length=200)
def __unicode__(self):
return u'Rating %s' % self.title
class Meta(EntryAbstractClass.Meta):
abstract = True
Here is my zinnia entry base model path in settings.py
ZINNIA_ENTRY_BASE_MODEL = 'happy.happy_models.Happy'
I just noticed this at my console
/zinnia/models.py:302: RuntimeWarning: happy.happy_models.Happy cannot be imported
Here is my directory setup
happy/
admin.py
happy_models.py
views.py
What I might be doing wrong when extending entry?
I finally found out -- by running the server on interactive mode I was able to debug. The sample code had to be modified to this:-
from zinnia.models import EntryAbstractClass
instead of
from zinnia.models.entry import EntryAbstractClass