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

Already on GitHub? Sign in to your account

Better support for custom models #2639

DylannCordel opened this Issue Feb 13, 2014 · 15 comments


None yet
9 participants

DylannCordel commented Feb 13, 2014

We, WebU (www.webu.coop), are using DjangoCMS and we need some custom model
support improvments. We would be happy if it could be done in DjangoCMS.
Here is the features we (ollb an I) would like to develop :

CMS page like integration of custom models in admin interface

Purpose :

  • Add a link in change_list to load the detail view in the main iframe
  • Add an icon link in change_list to edit the model without placeholder

Technical notes :

  • The idea is to add a CustomModelAdmin class.

Easy use of models in Pages

When manipulating a lots of custom models, it would be very handy to have
generic list plugin and generic detail view.

Generic custom model list plugin

Provide a way to create generic plugin that displays a list of custom models instances.

Available dynamic options to configure the display of the list :

  • max number of instances to display
  • use a pager or not (is so define a min number of instances per page)
  • title of the list
  • define parameters for dynamic filters (cf filters)
  • enable a search form and choose fields available
  • enable a sort form and choose fields available
  • link to the view page

Available static options to configure the display of the list :

  • define a static filter
  • define the dynamic filters
  • define fields available for search
  • define fields available for sort
  • enable or not a "create new" link

Dynamic and static filters

We may want to restrict the displaid list of instances (ie : news.published = True) :

  • When creating the Plugin Class, to have a base restriction (static filter)
  • When creating the Plugin instance, to have a "contextual" restriction
    (dynamic filter). ie :
    • on home page, we only want news.home = True
    • on news page, we want all news from this year
    • on archive page, we want all news from past years.

Generic custom model detail view

  • Provide a generic DetailView with specific permission verification from model, else
    generic permission fallback.
  • URL configuration should be automagically discovered if not specified
    (ie : find a slugfield, else a unique (combination of) field(s).)

Add a generic way to integrate a custom model in cms_toolbar

Purpose :

  • One click access to the custom model admin change list
  • Remove page specific stuff menu in cms_toolbar on a detail custom model view
    In a detail custom model view, the page menu missleads the user because actions
    are related to the app hook page (not the current one, whicho doens't exist in
  • Add optionaly a custom model specific menu like the page one
  • Improve language menu to support hvad if custom model use it
  • Improve history menu to support custom model

digi604 commented Feb 14, 2014

I like the ideas.... maybe write up some example api usages...

@digi604 digi604 added this to the Some Day milestone Feb 14, 2014


ollb commented Apr 8, 2014

We've started the branch feature/custom-models : webu/django-cms@b60cad9

Here is the documentation we wrote : https://github.com/webu/django-cms/blob/feature/custom-models/docs/extending_cms/custom_model.rst

Some current thoughts :

  • we initially started a solution based on abstract classes. It's fine for self build models, but it doesn't allow us to integrate existing models of other applications without modifying them. So, we are likely to move to a "register" way similar to how reversion integrates itself to existing models.
  • for convenience, several ModelAdmin options are auto-generated. We are wondering whether it would be better to disable by default this feature.
  • we would like to provide a way to organise models in toolbar without following the annoying default organisation structured in applications and models.

digi604 commented Apr 9, 2014

This is nice and could benefit a lot of 3rd party apps. Will need to have a look at the code though... could you open a PR and mark it as WIP?


jrief commented Sep 15, 2014

+1 from my side.


mkoistinen commented Oct 26, 2014

@DylannCordel Where do you stand with this one? Sounds like a great feature for the CMS.


DylannCordel commented Oct 27, 2014

@mkoistinen we are currently under the water with some projects 😭
This is on the first place of our "free time todo list" ;-)


evildmp commented Dec 9, 2014

There seems to be some support for this. I'd like to see some more comments on the concept from other core maintainers.


mkoistinen commented Jan 12, 2015

Hey all, this looks like it'd be a nice addition. @DylannCordel whats the status from your side? Been nearly a year since this was opened now.


DylannCordel commented May 26, 2015

Hi all,

I'll have some "free" days to work on this PR this week :-). But it would be great if I could have some advices or feed-back on the already done code in PR #3034 (I'm a little frightened by this PR ^_^)


DylannCordel commented Jun 4, 2015

Still a WIP, but I updated documentation and tests specifications about this feature (and some code but the "how" is less important than the "what")

Feedbacks are welcome : do you think this is coherent with the "Django-CMS way" to help dev to integrate their Custom Model in Django-CMS ?
For exemple, I'm not sure this is a good idea to manage search form and sort form in a CMSPlugin : I think developper should use a view if he needs this type of feature. I would remove those both features.


yakky commented Jun 5, 2015

This is just my opinion and has not been discussed within the technical board, but I'd like to have the least amount of code into the CMS core as possible, only the minimum required to get the things simpler for applications like the one you propose or aldryn-apphooks-config. Monolithic projects can be very complicated to maintain and become more and more slow at evolving over the time.
Looking at the PR I see that no core part of the CMS is changed, but it consists of additions, which makes me think that it can be an external application that improves the overall django CMS experience without being a fundamental part of it.

It's just my 2 cents (for real: I'm up to discuss this in details with no prejudice)

@yakky yakky closed this Jun 5, 2015

@yakky yakky reopened this Jun 5, 2015


yakky commented Jun 5, 2015

Sorry, I pressed the wrong button :)


FinalAngel commented Oct 19, 2015

If its feasible it should me a separate addon and not core. If the addon performs very good we can consider it being a core addon.

auvipy commented Mar 27, 2016

#3034 should the proposed changes stay on a 3rd party app?


FinalAngel commented May 30, 2016

@DylannCordel can this be achieved as separate addon from your end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment