Decoupling Forms from Model

92 views
Skip to first unread message

Jamesie Pic

unread,
Sep 17, 2017, 8:40:12 AM9/17/17
to django-d...@googlegroups.com
Hello everybody !

Currently, it's possible to override a model field to override the formfield method. This allows to generate a default form from a model with the ModelForm. This is something that other maintainers of small django apps providing with new form fields might also have seem users struggling with on GitHub or StackOverflow.

In Ponzu framework, they register a function for a model type which returns a form object. Example MarshalEditor function for their Song model in a Ponzu Example: https://github.com/ponzu-cms/examples/blob/master/news/examples/createable/content/song.go#L25

If Django had something similar then there would be no need for model Field.formfield anymore. Also, users would have more freedom to design how they want their default model forms to look like.

Thanks in advance for sharing some of your insight.

Tim Graham

unread,
Sep 18, 2017, 7:01:14 AM9/18/17
to Django developers (Contributions to Django itself)
Hi, maybe you forgot that you raised this topic before in https://groups.google.com/d/topic/django-developers/1qzFomJ7VzI/discussion. It's better to continue the existing thread so that past discussion is more easily viewable.

Jamesie Pic

unread,
Sep 18, 2017, 12:28:13 PM9/18/17
to django-d...@googlegroups.com
Thanks Tim, I had completely forgotten about this episode.

I've given up the idea of changing this (amongst other things) in Django and decided to work a layer on top of Django instead ( https://github.com/yourlabs/crudlfap ).

As far as I'm concerned, we can close this.

Thanks a heap for answering,
Have a great day.
Reply all
Reply to author
Forward
0 new messages