Login

Tag "raw_id_fields"

Snippet List

Link raw_id_fields (both ForeignKeys and ManyToManyFields) to their change pages

**UPDATE: Now works in Django 1.4** Based on luc_j:s snippet (http://djangosnippets.org/snippets/2108/) to show values in ManyToManyFields in the admin. This snippets does that, but also links each value to its corresponding admin change page. To use, just set the raw_id_fields to the value you want, and let your form inherit from ImproveRawIdFieldsForm.

  • admin
  • widget
  • django-admin
  • raw_id_fields
  • ManyToManyField
  • ForeignKey
Read More

Make hyperlinks for labels of raw_id_fields (jQuery)

The Django Admin site provides a "raw ID" feature for foreign keys that reference large tables. In the form view, the label of the referenced object will appear after the input. This snippet will make that label into a hyperlink that takes you to the form view for that object. To use this snippet, copy base_site.html into your templates/admin directory (if you haven't already), and paste this code into that file somewhere after the 'extends "admin/base.html"' directive. If you are already using jQuery, you can remove the first script tag. If you are already extending "extrahead", just paste the script tag(s) into the block you have created. [Documentation for raw_id_fields](http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields)

  • admin
  • jquery
  • raw_id_fields
Read More

2 snippets posted so far.