Skip to main content

Drag-to-reorder inline model admins for Django

Project description

Drag-to-reorder inline model admins for Django

Installation

pip install django-orderable-inlines

Add orderable_inlines to your INSTALLED_APPS.

Example

models.py:

from django.db import models

class Gallery(models.Model):
    name = models.CharField(max_length=16)

class Photo(models.Model):
    gallery = models.ForeignKey(Gallery)
    image = models.ImageField(upload_to='gallery_photos')
    order = models.PositiveIntegerField(default=1)

admin.py:

from django.contrib import admin
from gallery.models import Gallery, Photo
from orderable_inlines import OrderableTabularInline

class PhotoInline(OrderableTabularInline):
    model = Book
    orderable_field = 'order'

class GalleryAdmin(admin.ModelAdmin):
    inlines = [
        PhotoInline,
    ]

admin.site.register(Gallery, GalleryAdmin)

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-orderable-inlines-0.0.2.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file django-orderable-inlines-0.0.2.tar.gz.

File metadata

File hashes

Hashes for django-orderable-inlines-0.0.2.tar.gz
Algorithm Hash digest
SHA256 7651e41e9653c2cab79ae9faea2733e3094452704bc8775468b701a632c2c73f
MD5 d80e980087982676e93d8fe6e9e7511d
BLAKE2b-256 d2b6234282b50254607775e7a9162ddcac39ab0191cb483ed0101e5892cac91f

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