Tuesday, August 4, 2015

help with list_editable and raw_id_fields

Hi eveyone,
  I am having issues with list_editable and raw_id_fields. I am adding one field to both attributes like this

lass LocationDataReview(admin.ModelAdmin):
list_display = ('country', 'state', 'city', 'area','location')
list_editable = ('location',)
raw_id_fields = ("location", )
list_per_page = 30
ordering = ['country', 'state', 'city', 'area']


And it displays correctly, there's a lookup widget in the list, but when I click on it it takes me to the change page instead of the search pop up for the related field.

I am using django 1.8.2 for some time now so it shouldn't be a cache issue (as I read some people said). I have anyway cleared the cache just in case.

I see this in the page source

<td class="field-location nowrap"><input class="vForeignKeyRawIdAdminField" id="id_form-0-location" name="form-0-location" type="text"><a href="/admin/general/location/?_to_field=id" class="related-lookup" id="lookup_id_form-0-location" title="Lookup"></a></td>

and I see the RelatedObjectLookup.js is loaded. But it just takes me to the change page anyway.

Any ideas?

Also, I just need the location field to select from a catalog, and fill in the rest of the fields (country, state etc), but I don't really need the location foreign key in my model. Is there any way to avoid it and still show it in the admin list page? For what I have seen the only way I have to do that is to just create my own views and add that url to the admin site. I tried using a custom form for the list and add the extra field but it didn't work out, the extra field just does not get displayed.

Thanks for your help!

Marcela



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eeeb06ce-9c4e-4382-be0b-ce38dbc286f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment