Skip to main content

Django application that allows yo yout generic relations have a nice admin widget

Project description

Information

Generic Foreign Key is a Django application that allows your Generic relations have a nice widget in the admin

It is distrubuted under the terms of the GNU Lesser General Public License <http://www.gnu.org/licenses/lgpl.html>

Dependencies

<script src="/media/js/jquery-1.2.6.min.js"></script>

Installation

Install in your base_site.html of django admin

<script src-"/media/js/jquery-1.2.6.min.js"></script>

In your settings.py

Add a setting EXCLUDE_CONTENT_TYPES, with the content types to exclude. This step is not necesary, but advisable

EXCLUDE_CONTENT_TYPES = (('auth', 'group'), ('auth', 'messege'), ...)

You can filter too, with this setting

FILTER_CONTENT_TYPES = (('auth', 'group'), ('auth', 'messege'), ...)

If you want to a UI more friendly to select a the content

SEARCH_MODELADMIN = True

And in your change_list.html overwrite extrastyle block:

{% block extrastyle %}
  {{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />
  {% if cl.formset %}
      <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />
      {% url admin:jsi18n as jsi18nurl %}
      <script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
  {% endif %}
  {{ media }}
  {% if not actions_on_top and not actions_on_bottom %}
      <style>
      #changelist table thead th:first-child {width: inherit}
      </style>
  {% endif %}
  {{ generic_fk_media }}
{% endblock %}

In your ModelAdmin

Extend yout ModelAdmin with GenericAdmin

class MyModelAdmin(GenericAdmin):
    ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-genericforeignkey-0.60.3.tar.gz (13.6 kB view details)

Uploaded Source

File details

Details for the file django-genericforeignkey-0.60.3.tar.gz.

File metadata

File hashes

Hashes for django-genericforeignkey-0.60.3.tar.gz
Algorithm Hash digest
SHA256 464506d0a046224d86ff81c235f925dc86088796c5356a057ed2f5ddb08a5c0a
MD5 2195d0f143af3af63aaa1b8560e33c25
BLAKE2b-256 53f2c25457b2d5fdb13e3f8dbe0d72e089922388727f5f4d482c441f68b2a2d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page