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.4.tar.gz (2.8 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-orderable-inlines-0.0.4.tar.gz
Algorithm Hash digest
SHA256 953277df53b67298727f6d878adbf2d5439b2231b9de8f94907cbab004c726fe
MD5 ddd4e093b7a2988fca610a6975b28555
BLAKE2b-256 0d84ac641022c92d072dd2875f1a9ebb7d32d7722e30536a35e12f00d7fd59a6

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