Forms Integration & Django Admin

24 views
Skip to first unread message

Richard

unread,
Aug 18, 2009, 12:14:22 AM8/18/09
to dojango-users
I see that Dojango 0.4 subclasses Django forms and uses Dojo widgets.
Has anyone tried to get the Django admin app to use these forms
subclasses? If so, any pointers would be most welcome.

Julian Moritz

unread,
Aug 18, 2009, 1:42:15 AM8/18/09
to dojang...@googlegroups.com
Hi Richard,

Richard schrieb:
> I see that Dojango 0.4 subclasses Django forms and uses Dojo widgets.
> Has anyone tried to get the Django admin app to use these forms
> subclasses? If so, any pointers would be most welcome.

with another app I've been using custom widgets with django-admin. Just
have a look at the following code of django-tinymce:

http://django-tinymce.googlecode.com/svn/trunk/docs/.build/html/usage.html#using-the-widget

I think you can copy and modify that code.

Best regards
Julian

> >
>

Tobias von Klipstein

unread,
Aug 18, 2009, 2:24:06 AM8/18/09
to dojang...@googlegroups.com
Hi Richard,

I think your question wasn't about just integrating a Rich Text Editor!? I suppose you want to have a complete ajaxified interface, that is using the dojo grid, client-side form validation, autocomplete comboboxes ...

As you've already seen, the dojango fields/widgets are extending the normal django form fields/widgets from django.forms.*, but are yet not extending the widgets of the contrib app: django.contrib.admin.widgets. I suppose for doing an integration to the admin these widgets also need to be subclassed. As from a quick lookup there mainly is just work do be done for using the right Dojo widget, if a foreign key needs to be selected. All other widget extensions should be straightforward. Would be great, if you could help on that.

And you could also ask Diego:


for using Dojango in the admin. He already wrote that he has a simple solution for creating a full admin interface. Also need to ask him :-)

Regards, Tobias
---

http://uxebu.com - AJAX and JavaScript Experts
You need AJAX, RIA, JavaScript and all this modern stuff? We've got it!

uxebu Consulting Ltd. & Co. KG
Richard-Strauss-Str. 21
81677 München

Amtsgericht München
Handelsregister HRA 93461

Persönlich haftende Gesellschaft:
uxebu Ltd. - Sitz München
Amtsgericht München
Handelsregister HRB 176791
Geschäftsführer: Wolfram Kriesing, Nikolai Onken, Tobias von Klipstein

Julian Moritz

unread,
Aug 18, 2009, 12:42:31 PM8/18/09
to dojang...@googlegroups.com
Hi,

Tobias von Klipstein schrieb:


> Hi Richard,
>
> I think your question wasn't about just integrating a Rich Text Editor!?

I think the question was about integration own widgets in the admin
interface. The link I quoted is about several ways how to integrate the
tinymce-widget into the admin interface.

Best regards
Julian

Tobias von Klipstein

unread,
Aug 18, 2009, 12:45:22 PM8/18/09
to dojang...@googlegroups.com
Hey Julian,

oh. that was a misunderstanding. Maybe it was too early anwering this
question :-)

Sorry for that, Tobias

Julian Moritz

unread,
Aug 18, 2009, 1:39:08 PM8/18/09
to dojang...@googlegroups.com
Hi Tobias,

Tobias von Klipstein schrieb:
> Hey Julian,
>
> oh. that was a misunderstanding. Maybe it was too early anwering this
> question :-)
>
> Sorry for that, Tobias
>

no problem!

Best regards
Julian

Richard Laager

unread,
Aug 18, 2009, 5:18:25 PM8/18/09
to dojang...@googlegroups.com
On Tue, 2009-08-18 at 08:24 +0200, Tobias von Klipstein wrote:
> I suppose you want to have a complete ajaxified interface, that is
> using the dojo grid, client-side form validation, autocomplete
> comboboxes ...

Exactly. I want to drop in something and have it work. :)

> As from a quick lookup there mainly is just work do be done for using
> the right Dojo widget, if a foreign key needs to be selected.

We're currently working on a foreign key combo box right now. It needs a
little more work before we'd consider it done. I can certainly share
that code.

Richard

signature.asc

Tobias von Klipstein

unread,
Aug 18, 2009, 5:39:19 PM8/18/09
to dojang...@googlegroups.com
Hey Richard,

another developer on the mailinglist (http://groups.google.com/group/dojango-users/browse_thread/thread/c88f62f005be7968) also had a nice idea for defining a FilteringSelect/ComboBox, where just a URL is passed as parameter to the widget. In his case it is a storename, but to generalize it, it would be a simple URL to the store then:

class FilteringSelect(DojoWidgetMixin, Input):
    dojo_type = 'dijit.form.FilteringSelect'
    valid_extra_attrs = [
        'required',
        'help_text',
    ]
    extra_dojo_require = [
        'dojox.data.QueryReadStore',
    ]
    def render(self, name, value, url, label="name", search="name", attrs=None):
        store_name = '%sStore' % name
        attrs = {'store':store_name, 'searchAttr':search, 'labelAttr':label}
        extra_html='<div dojoType="dojox.data.QueryReadStore"
url="%s" jsId="%s"></div>' % (url, store_name)
        return mark_safe(extra_html+super(FilteringSelect,
self).render(name, value, attrs))

Nearly the same would need to be implemented for a ComboBox. But I would be happy for a more enhanced solution.

Regards, Tobias
Reply all
Reply to author
Forward
0 new messages