django-blog-zinnia / cmsplugin-zinnia

Bridge between django-blog-zinnia and django-cms
BSD 3-Clause "New" or "Revised" License
53 stars 46 forks source link

Adding extension app to installed app leads to error #38

Closed l4rth closed 9 years ago

l4rth commented 9 years ago

Hi,

i added an extension to my django-cms 'zinnia_association' which extends the entry with a foreign key. I also added an admin.py with the integration for the admin panel. I followed the guide in the documentation. Now when i add 'zinnia_association' to the INSTALLED_APPS (after zinnia) I get the error:

Unhandled exception in thread started by <function wrapper at 0x104bf6320>
Traceback (most recent call last):
  File "/myproject/venv/lib/python2.7/site-packages/django/utils/autoreload.py", line 93, in wrapper
    fn(*args, **kwargs)
  File "/myproject/bbd/venv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 101, in inner_run
    self.validate(display_num_errors=True)
  File "/myproject/venv/lib/python2.7/site-packages/django/core/management/base.py", line 314, in validate
    raise CommandError("One or more models did not validate:\n%s" % error_text)
django.core.management.base.CommandError: One or more models did not validate:
cmsplugin_zinnia.latestentriesplugin: 'categories' has an m2m relation with model zinnia.Category, which has either not been installed or is abstract.
cmsplugin_zinnia.latestentriesplugin: 'authors' has an m2m relation with model zinnia.Author, which has either not been installed or is abstract.
cmsplugin_zinnia.selectedentriesplugin: 'entries' has an m2m relation with model <class 'zinnia.models.entry.Entry'>, which has either not been installed or is abstract.
bittner commented 9 years ago

Please add links to the "zinnia_association" (unknown to Google) and the "guide in the documentation". How can someone help you if they can't double-check the steps you say you have already done?

You have done a ./manage.py syncdb --migrate, haven't you?

What's your Django version, django CMS version, Zinnia version, cmsplugin-zinnia version?

l4rth commented 9 years ago

I think I wrote it wrong: I actually built the extension. But while going on, I found out that I used the way zinnia wants me to extend the entry model, which is not the way cmsplugin-zinnia wants it. So i will have to reformulate my question to: Is there a way (Tutorial or something) how to extend the Entry Model of zinnia with extensional fields like in zinnia itself?

I am providing source coude maybe this can help.

First I have created a package called zinnia_association and then built the model (zinnia_association/models.py):

from django.db import models
from zinnia.models_bases.entry import AbstractEntry

class AssociationBlog(AbstractEntry):
    association = models.ForeignKey("associations.Association",
                                blank=True,
                                default=None,
                                null=True,
                                related_name='news')

    def __str__(self):
        return 'AssociationBlog %s' % self.title

    class Meta(AbstractEntry.Meta):
        abstract = True

I also use south so I added it to south and added the Entry Base Model

SOUTH_MIGRATION_MODULES = {
    'zinnia': 'zinnia_association.migrations.zinnia',
}
ZINNIA_ENTRY_BASE_MODEL = 'zinnia_association.models.AssociationBlog'

Additionally I built an Admin part for it

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from zinnia.models.entry import Entry
from zinnia.admin.entry import EntryAdmin

class AssociationBlogAdmin(EntryAdmin):

    fieldsets = ((_('Content'), {'fields': (
       ('title', 'status'), 'content', 'image', 'association')}),) + \
            EntryAdmin.fieldsets[1:]

admin.site.unregister(Entry)
admin.site.register(Entry, AssociationBlogAdmin)

Which now i think should be altered to fit the django-cms admin part. Anyway I also added the package to the installed_apps

INSTALLED_APPS = (
    ... ,
    'zinnia',
    'cmsplugin_zinnia',
    'zinnia_ckeditor',
    'zinnia_extra'
)

And I get this error I posted above.

Fantomas42 commented 9 years ago

For me everything should be fine, but I don't know where your issue comes from.

If you want that someone do support for you, you must provide your code, not snippets, because developers are not medium, and nobody will spent time to reconstruct your project from copy/paste to help you.

Regards

l4rth commented 9 years ago

I will try to provide code later, i have to remove things from the whole fact (I know developers are not medium i am one by myself but not in this field).

So what I get to know from your post, it's the right way to implement such an extension to the entry model even through django-cms?

Fantomas42 commented 9 years ago

So what I get to know from your post, it's the right way to implement such an extension to the entry model even through django-cms?

Normally even with django-cms, extensions for the Entry model should work. For the now, I don't know such a limitation like that. Investigations with a concrete example are needed.

l4rth commented 9 years ago

I feel so dump. While I rebuild parts of the app in order to show the error I found out that, due to strange South problems, I had removed mysite.apps.zinnia_association before and later just added zinnia_association to the Installed_apps which lead to this error and which i overlooked several times. I am very sorry, that I may have wasted your time.

Fantomas42 commented 9 years ago

Lol, it's happen ! If your issue is solved, it's great.