• Stars
    star
    678
  • Rank 66,609 (Top 2 %)
  • Language
    Python
  • License
    Other
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Django admin classes that allow for nested inlines

django-nested-admin

build_badge coverage_badge docs_badge

django-nested-admin is a project that makes it possible to nest admin inlines (that is, to define inlines on InlineModelAdmin classes). It is compatible with Django 3.2+ and Python 3.7+ and works with or without Grappelli. When Grappelli is not installed it allows Grappelli-like drag-and-drop functionality.

Installation

The recommended way to install django-nested-admin is from PyPI:

pip install django-nested-admin

Alternatively, one can install a development copy of django-nested-admin from source:

pip install -e git+git://github.com/theatlantic/django-nested-admin.git#egg=django-nested-admin

If the source is already checked out, use setuptools to install:

python setup.py develop

Configuration

To use django-nested-admin in your project, "nested_admin" must be added to the INSTALLED_APPS in your settings:

INSTALLED_APPS = (
    # ...
    'nested_admin',
)

If youโ€™re using django-grappelli, you will also need to add to include nested_admin.urls in your urlpatterns:

urlpatterns = [
    # ...
    path('_nested_admin/', include('nested_admin.urls')),
]

Example Usage

In order to use django-nested-admin, use the following classes in place of their django admin equivalents:

django.contrib.admin nested_admin
ModelAdmin NestedModelAdmin
InlineModelAdmin NestedInlineModelAdmin
StackedInline NestedStackedInline
TabularInline NestedTabularInline

There is also nested_admin.NestedGenericStackedInline and nested_admin.NestedGenericTabularInline which are the nesting-capable versions of GenericStackedInline and GenericTabularInline in django.contrib.contenttypes.admin.

# An example admin.py for a Table of Contents app

from django.contrib import admin
import nested_admin

from .models import TableOfContents, TocArticle, TocSection

class TocArticleInline(nested_admin.NestedStackedInline):
    model = TocArticle
    sortable_field_name = "position"

class TocSectionInline(nested_admin.NestedStackedInline):
    model = TocSection
    sortable_field_name = "position"
    inlines = [TocArticleInline]

class TableOfContentsAdmin(nested_admin.NestedModelAdmin):
    inlines = [TocSectionInline]

admin.site.register(TableOfContents, TableOfContentsAdmin)

Testing

django-nested-admin has fairly extensive test coverage. The best way to run the tests is with tox, which runs the tests against all supported Django installs. To run the tests within a virtualenv run pytest from the repository directory. The tests require a selenium webdriver to be installed. By default the tests run with phantomjs, but it is also possible to run the tests with the chrome webdriver by passing --selenosis-driver=chrome to pytest or, if running with tox, running tox -- --selenosis-driver=chrome. See pytest --help for a complete list of the options available.

Contributing

This project uses webpack for building its javascript and css. To install the dependencies for the build process, run npm install from the root of the repository. You can then run npm run build to rebuild the static files.

License

The django code is licensed under the Simplified BSD License. View the LICENSE file under the root directory for complete license and copyright information.

More Repositories

1

django-chosen

django FormFields using the Chosen javascript plugin for jQuery
JavaScript
140
star
2

citylab-data

Resources, data, and methodology for CityLab data journalism projects
R
95
star
3

django-select2-forms

Django form fields using the Select2 jQuery plugin
Python
82
star
4

django-cropduster

Image uploader and cropping tool to create thumbnails at various aspect ratios
JavaScript
81
star
5

django-xml

A python module which provides an abstraction to lxml's XPath and XSLT functionality in a manner resembling django database models.
Python
43
star
6

django-autosave

Reusable autosave for the Django Admin
Python
42
star
7

thumbor-video-engine

An engine and tools for manipulating videos with thumbor using ffmpeg
Python
31
star
8

django-mysqlndb-backend

Provides a django database backend that works with MySQL Cluster's NDB storage engine
Python
12
star
9

python-monkey-business

Utility functions for monkey-patching python code
Python
11
star
10

python-blogger

A fork of python-blogger, a python wrapper around the Blogger, Metaweblog, Wordpress, MovableType API
Python
11
star
11

django-curation

Not to be confused with django-curated
Python
10
star
12

django-generic-plus

Django model field that behaves as both a GenericForeignKey and a FileField
Python
8
star
13

django-south

A git mirror of the django south mercurial repository
Python
6
star
14

django-partner-feeds

Save basic information from partner feeds in a database
Python
5
star
15

django-ko-demo

A rough demo of using nested inlines and knockout js to create a wysiwyg interface in the django admin
CSS
5
star
16

django-dart

DoubleClick DART tags for Django
Python
4
star
17

py4j-highcharts

A Py4J gateway server in Java that allows python applications to rasterize SVG to PNG
JavaScript
4
star
18

django-polymorphic-foreignkey

A polymorphic ForeignKey field that acts like a generic ForeignKey
Python
3
star
19

go-pensieve

Parse Krux data feed files and import into a Pilosa DB
Go
3
star
20

django-selenosis

Helpers for writing selenium tests for Django (formerly django-admin-testutils)
Python
3
star
21

jinja2-template-cache

A bytecode cache for jinja2 using django cache backends
Python
3
star
22

host

Scraping and parsing logic for David Foster Wallace's Host.
HTML
3
star
23

django-phatpages

Python
2
star
24

wpt-slack-spreadsheet

Profile a URL in WPT and send the relevant results to Slack and store all the results in a Google Spreadsheet.
JavaScript
2
star
25

django-fatpages

Flatpages for Django that integrates with the CKEditor
Python
2
star
26

blueconic

Blueconic Python library
Python
1
star
27

pysilverpop

Python Wrapper for Silverpop
Python
1
star
28

djangotoolbox

Mirror of the djangotoolbox bitbucket repository for django-nonrel
Python
1
star
29

django-admin-testutils

Helpers for writing selenium tests for the django admin
Python
1
star
30

kruxpy

Kruxpy is a library for dealing with the Krux / Salesforce DMP API
Python
1
star
31

django-contact-form

git clone of django-contact-form https://bitbucket.org/ubernostrum/django-contact-form/
Python
1
star
32

gulp-htmlhint-junit-reporter

jenkins-friendly junit reporter for gulp-htmlhint
JavaScript
1
star