Gauravwagh / django-grappelli

Automatically exported from code.google.com/p/django-grappelli
Other
0 stars 0 forks source link

Feature: customizeable related_lookup results for raw_id_fields #340

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have sometimes the need to display something different than the __unicode__ 
of a related object next to raw_id_fields.

Therefor i patched the grappelli.views.related_lookup function to return the 
result of the objects admin-model.get_related_lookup method if it exist.
The _get_generic_repr javascript functions tests the Content-Type of the ajax 
response and in case of 'text/html' insert the response as html.

a brief example is in the attached file.

Original issue reported on code.google.com by defaultw...@gmail.com on 14 Jan 2011 at 1:02

Attachments:

GoogleCodeExporter commented 9 years ago
generally, not a bad idea.

what I don´t like about it:
1. the fact that we add a method get_related_lookup.
2. using text/html as in order to check for the response.
3. and most important, the related-lookups should work like a raw-id-field 
(that´s the basic idea).

so, let´s see if we get feedback from other people.

is it possible to use a custom widget instead?

regards,
patrick

Original comment by sehmaschine on 14 Jan 2011 at 1:15

GoogleCodeExporter commented 9 years ago
@1 adding an "optional" method to the admin class doesn't hurt me. It wouldn't 
even hurt me if its on the model it self.

@2 changing the whole response to json would anyway be my prefered way.
In this way the whole process could be cleaned up alot.
e.g.: {data:'/media/image_thumb.jpg', type: 'thumbnail'}

@3 honestly, it's a while since I have used the default admin interface. Does 
it make a lookup for this fields?

my basic usecase for this is that i usually store every uploaded mediafile 
togehter with its exif data, title, copyright,... in a media model. In the 
admin interface editors connect instances of these model to other objects 
instead of images directly.
so i typically end up with a inline model for related images. showing editors 
the filename instead of thumbnails makes them stiching needles into the voodoo 
doll representation of me.

Original comment by defaultw...@gmail.com on 14 Jan 2011 at 1:51

GoogleCodeExporter commented 9 years ago
I´ve been giving this issue some thoughts and I do believe that you should 
open a ticket for django since this issue is more related to the original 
admin-interface than to grappelli. I totally understand the usecase and I´d 
like to see the possibility to customize raw-id-field as much as possible. as 
already mentioned, the raw-id-field includes a lookup (with no immediate 
response) – so I think that this lookup needs to be changed before we discuss 
any implementation with grappelli.

any thoughts on this?

Original comment by sehmaschine on 23 Jan 2011 at 3:34

GoogleCodeExporter commented 9 years ago
closing this as "wontfix" for now since it´s primarily related to django (and 
not grappelli) IMO. hope that raw-id-fields will be easier to customize in the 
near future.

Original comment by sehmaschine on 2 Feb 2011 at 6:30

GoogleCodeExporter commented 9 years ago

Original comment by sehmaschine on 2 Feb 2011 at 6:30

GoogleCodeExporter commented 9 years ago
I think it's more related to grappelli: what about introducing a new projekt 
setting like:

GRAPPELLI_RELATED_RENDER_METHOD = 'foo'

and use it in the related_lookup()-method if exists in the model or modeladmin?

Original comment by stefanoe...@gmail.com on 18 May 2011 at 7:46

GoogleCodeExporter commented 9 years ago
I don´t agree with that. as long as it´s so tricky to deal with 
raw-id-fields, I´m not willing to add more complexity to grappelli (it´s much 
better to simplify the django-side and then add features to grappelli). sorry.

Original comment by sehmaschine on 21 May 2011 at 8:29