Integration with django-categories

35 views
Skip to first unread message

asdfg

unread,
Mar 2, 2011, 10:52:32 AM3/2/11
to django-...@googlegroups.com
Hi

I want to integrate django-categories (https://github.com/washingtontimes/django-categories) with django-page-cms so that when adding or editing pages in admin, there's an extra 'categories' field available.

For my own custom apps, it's simply a case of registering my model to the categories model as a foreign key:

import categories
categories.register_m2m(MyModel, 'categories', {'related_name':'mymodel_categories'})

However, I'm struggling to figure out how to integrate it with page-cms. Can anyone shed any light on this - either from direct experience of integrating with this app, or more generally?

Thanks
 


asdfg

unread,
Mar 3, 2011, 4:57:13 AM3/3/11
to django-...@googlegroups.com
In the absence of anyone being able to shed light on this, perhaps I could take things back a step to ask whether its possible to add custom fields to the page model and if so, how? If I could do this then I might be able to figure out the next step to hooking it up to the categories app.

faden

unread,
Mar 3, 2011, 7:36:00 AM3/3/11
to django-page-cms
For both solutions, I would be surprised if it would be possible to
add a field without changing the original CMS code.
But I guess I would to subclass the model and add the field. But the
CMS admin interface will probably not follow.

In both case, I think it could be done with minor changes to the admin
application or the model:

https://github.com/batiste/django-page-cms/blob/master/pages/admin/__init__.py

asdfg

unread,
Mar 3, 2011, 9:09:23 AM3/3/11
to django-...@googlegroups.com
In the end I decided to just edit the pages module code itself (for now anyway).

For anyone else trying to do the same thing, or similar, you can dispense with the django-categories register_fk / register_m2m function and just add a ManyToManyField to pages.models.Page. You then just need to add the field name to the PageAdmin class in pages/admin/__init__.py

Clearly, subclassing the pages model would be more elegant, but I guess that would require changing all the references to Pages in my project, which, when I'm using virtualenv anyway, seems a bit unnecessary.
Reply all
Reply to author
Forward
0 new messages