Skip to content

FundersClub/django-orderable-inlines

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-orderable-inlines

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 = Photo
    orderable_field = 'order'

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

admin.site.register(Gallery, GalleryAdmin)

About

Drag-to-reorder inline model admins for Django

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 89.1%
  • HTML 8.4%
  • Python 2.4%
  • CSS 0.1%