Skip to main content

Recursive nesting of inline forms for Django Admin

Project description

django-nested-inline

Nested inline support for Django admin

Most of the code from this package is from https://code.djangoproject.com/ticket/9025

Github

https://github.com/s-block/django-nested-inline

Installation

pip install django-nested-inline

Usage

Add nested_inline to INSTALLED_APPS

# models.py

from django.db import models

class TopLevel(models.Model):
    name = models.CharField(max_length=200)

class LevelOne(models.Model):
    name = models.CharField(max_length=200)
    level = models.ForeignKey('TopLevel')

class LevelTwo(models.Model):
    name = models.CharField(max_length=200)
    level = models.ForeignKey('LevelOne')

class LevelThree(models.Model):
    name = models.CharField(max_length=200)
    level = models.ForeignKey('LevelTwo')


# admin.py

from django.contrib import admin
from nested_inline.admin import NestedStackedInline, NestedModelAdmin
from example.models import *

class LevelThreeInline(NestedStackedInline):
    model = LevelThree
    extra = 1
    fk_name = 'level'


class LevelTwoInline(NestedStackedInline):
    model = LevelTwo
    extra = 1
    fk_name = 'level'
    inlines = [LevelThreeInline]


class LevelOneInline(NestedStackedInline):
    model = LevelOne
    extra = 1
    fk_name = 'level'
    inlines = [LevelTwoInline]


class TopLevelAdmin(NestedModelAdmin):
    model = TopLevel
    inlines = [LevelOneInline]


admin.site.register(TopLevel, TopLevelAdmin)

Minifying Javascript

Released versions of this library should have a minified version of the js.

Minification is done with uglifyjs. If npm is installed on your system, you can install uglifyjs with the command:

npm install -g uglify-js

Then change to the directory where the file 'inlines-nested.js' and run the following command:

uglifyjs --compress --mangle --output ./inlines-nested.min.js -- inlines-nested.js

Releasing to PyPi

Create a file at $HOME/.pypirc and put the following text inside:

[pypi]
username = __token__
password = <Token from pypi>

Make sure the dependencies for this project are installed:

pip install django

Then install the build tool:

pip install build

Next run the distribution build of the project:

python -m build

Lastly, push the release to pypi

twine upload dist/*

Changelist

0.4.6:

  • Support django 4.1
  • Fix inline media error (#130)
  • Fix error when using 'save as new' (#149)
  • Add .fieldBox styling for django 2.1+ (#114)
  • Fix select2 import for Django >=2.2 (#150)
  • Fixed FieldDoesNotExist import to support Django>=3.2 (#147)

0.4.5 - Support django 4.0 and django-csp

0.4.4 - Add formset:added and formset:removed events (#97)

0.4.3 - Update media so it expects to find jquery in the right place. (#75)

0.4.2 - Fix assets

0.4.1 - Fix permission checks

0.4.0 - Added support for Django 3.0

0.3.7 - added support for django 1.10, fix unique fieldset id

0.3.6 - added support for django 1.9

0.3.5 - Removed deprecated methods and updated for Django 1.8/1.9

0.3.4 - added licence and updated for python 3

0.3.3 - fixed bug where inlines without inlines would cause an error

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-nested-inline-0.4.6.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_nested_inline-0.4.6-py2.py3-none-any.whl (25.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-nested-inline-0.4.6.tar.gz.

File metadata

  • Download URL: django-nested-inline-0.4.6.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for django-nested-inline-0.4.6.tar.gz
Algorithm Hash digest
SHA256 e57b55858d112364dfb112bbcdabb888e581d1677d31c1cac3bdcef6c890dc61
MD5 2c5e505cfaf9c16fbb57f3599d270382
BLAKE2b-256 3c8b29a211b9d5c6ec6a342e956313eb92f0709f14bc131d07165818dd5648a5

See more details on using hashes here.

File details

Details for the file django_nested_inline-0.4.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_nested_inline-0.4.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4fc6f0e78b3b5411b4bb7f180bb984831b88874bda48e49a14307baff5da5f12
MD5 9064e345fb004d022c82dc48979c6010
BLAKE2b-256 235f99dde59e13c23ff1b5054e8238b2a7d27de06f8f27a4e7ef150ea88a4ad9

See more details on using hashes here.

Supported by

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