Using FilteringSelect + QueryReadStore + django admin

67 views
Skip to first unread message

Diego Andrés Sanabria Martin (diegueus9)

unread,
Jul 31, 2009, 10:17:40 AM7/31/09
to dojang...@googlegroups.com
Hi guys,

I'm working with the google app engine using app-engine-patch and
dojango, i have to integrate many things of dojo in the admin
interface, in first instance i do that with FilteringSelect and
QueryReadStore for a Reference property in a model. I was code this
"widget":

class eFilteringSelect(DojoWidgetMixin, Input):
dojo_type = 'dijit.form.FilteringSelect'
def render(self, name, value, attrs=None):
storename = '%sStore' % name
attrs = {'store':storename, 'searchAttr':'nombre' }
extra_html='<div dojoType="dojox.data.QueryReadStore"
url="/store/%s/" jsId="%s"></div>' % (name,storename)
return mark_safe(extra_html+super(eFilteringSelect,
self).render(name, value, attrs))

And works, mostly ... I mean, when i want save the model there is a error:
Choose a valid option.
aghlZm8tY29uZHIqCxIbZmFsbGVjaW1pZW50b3NfbG9jYWxpemFjaW9uIglib2dvdGEtZGMM
...

In the other hand, when i read a saved model, in the admin don't show
me the name but the key is a value in the input, how i can fix that?

--
Diego Andrés Sanabria
Ingeniería de Sistemas Universidad Distrital
about:me http://www.google.com/profiles/diegueus9
cel 3015290609

Sent from Bogota, DC, Colombia

klipstein

unread,
Aug 1, 2009, 6:43:34 AM8/1/09
to dojango-users
Hi Diego,

seems like your store is returning wrong data. To help you on that, it
is nescessary that you post your returned store data.

Do you get the "Choose a valid option" error within JavaScript or in
Django? Some people reported problems with the FilteringSelect and
QueryReadStore and maybe these discussions will help you on that:

http://stackoverflow.com/questions/472059/filteringselect-with-a-queryreadstore-selection-doesnt-stick
http://trac.dojotoolkit.org/ticket/6071

For your second question: if you want to show the "nombre" key in your
FilteringSelect as label, you have to add labelAttr and name to the
FilteringSelect attributes:

attrs = {'store':storename, 'searchAttr':'nombre',
'labelAttr':'nombre', 'name':'nombre'}

The documentation of FilteringSelect on dojocampus explains that in
detail:

http://docs.dojocampus.org/dijit/form/FilteringSelect

But I really like the idea, how you combine the QueryReadStore/
FilteringSelect into a widget. Maybe this will be added to Dojango
somehow.

Regards, Tobias

On 31 Jul., 16:17, Diego Andrés Sanabria Martin (diegueus9)
> about:mehttp://www.google.com/profiles/diegueus9

Diego Andrés Sanabria Martin (diegueus9)

unread,
Aug 2, 2009, 1:26:08 AM8/2/09
to dojang...@googlegroups.com
On Sat, Aug 1, 2009 at 05:43, klipstein<tobias.k...@googlemail.com> wrote:
>
> Hi Diego,

Hi Tobias

>
> seems like your store is returning wrong data. To help you on that, it
> is nescessary that you post your returned store data.

The returned data is right.

>
> Do you get the "Choose a valid option" error within JavaScript or in
> Django? Some people reported problems with the FilteringSelect and
> QueryReadStore and maybe these discussions will help you on that:

Django.

>
> http://stackoverflow.com/questions/472059/filteringselect-with-a-queryreadstore-selection-doesnt-stick
> http://trac.dojotoolkit.org/ticket/6071

I fix that, because i was using ChoiceField (the django ChoiceField)
and this expected a param choices which in this case is a empty list,
i change this for a CharField.

>
> For your second question: if you want to show the "nombre" key in your
> FilteringSelect as label, you have to add labelAttr and name to the
> FilteringSelect attributes:
>
> attrs = {'store':storename, 'searchAttr':'nombre',
> 'labelAttr':'nombre', 'name':'nombre'}
>
> The documentation of FilteringSelect on dojocampus explains that in
> detail:
>
> http://docs.dojocampus.org/dijit/form/FilteringSelect

in this point the situation is the next:
I'm using google app engine with the app-engine-patch, and i have a
ReferenceProperty to a very large list of entities, and the view that
return the data, return a array with the key and the name (the key is
for the property an the name for the user), and save the data rigthly,
but when i get the entity i don't know how tell to the FilteringSelect
that this key must have a "human" value, do you understandme?

>
> But I really like the idea, how you combine the QueryReadStore/
> FilteringSelect into a widget. Maybe this will be added to Dojango
> somehow.

This is great, I wanna help with the project and i'm trying to package
dojango for debian :)
I have another ideas for the other widgets and how have a easy way for
with a few lines of code have a full admin interface with dojo, can i
join to the team?


>
> Regards, Tobias

Thanks for your time.
about:me http://www.google.com/profiles/diegueus9

Diego Andrés Sanabria Martin (diegueus9)

unread,
Aug 3, 2009, 1:15:02 PM8/3/09
to dojang...@googlegroups.com
For if someone in the interlol read this thread in the future i fixed it.
When the admin load the data request to
http://www.yourdomain.com/your_url_query_read_store/?id=
In your view you have cath that id and get the entity/model and return
the same json array with this data

And now i have another problem, this is not working with forms
inlines, dojo is not reading my markup...

Diego Andrés Sanabria Martin (diegueus9)

unread,
Aug 3, 2009, 5:15:56 PM8/3/09
to dojang...@googlegroups.com
On Mon, Aug 3, 2009 at 12:15, Diego Andrés Sanabria Martin
I fixed it too. The question is that the namestore can't content minus
(-) Why? i don't know, maybe this is a bug of dojo?

klipstein

unread,
Aug 18, 2009, 6:11:21 PM8/18/09
to dojango-users
Hey Diego,

sorry for not answering your questions earlier. See my answers inline:

> >> I fix that, because i was using ChoiceField (the django ChoiceField)
> >> and this expected a param choices which in this case is a empty list,
> >> i change this for a CharField.
It would be great if you could contribute the final widget you've
written.

> I fixed it too. The question is that the namestore can't content minus
> (-) Why? i don't know, maybe this is a bug of dojo?
Interesting, seems that is a bug within Dojo. If you could provide a
testcase you/I could file a bug within Dojo.

> >> This is great, I wanna help with the project and i'm trying to package
> >> dojango for debian :)
> >> I have another ideas for the other widgets and how have a easy way for
> >> with a few lines of code have a full admin interface with dojo, can i
> >> join to the team?
Having a debian for dojango would be awesome. A pypi package still
needs to be created and the setup.py for that is already present.
Maybe this could be used as a base for the debian package.
I'm really curious how you would write a dojofied admin interface.
Every help on enhancing Dojango is very welcome.

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