Nested inline support for Django admin
Most of the code from this package is from https://code.djangoproject.com/ticket/9025
https://github.com/s-block/django-nested-inline
pip install django-nested-inline
Add nested_inline to INSTALLED_APPS
# models.pyfromdjango.dbimportmodelsclassTopLevel(models.Model):
name=models.CharField(max_length=200)
classLevelOne(models.Model):
name=models.CharField(max_length=200)
level=models.ForeignKey('TopLevel')
classLevelTwo(models.Model):
name=models.CharField(max_length=200)
level=models.ForeignKey('LevelOne')
classLevelThree(models.Model):
name=models.CharField(max_length=200)
level=models.ForeignKey('LevelTwo')
# admin.pyfromdjango.contribimportadminfromnested_inline.adminimportNestedStackedInline, NestedModelAdminfromexample.modelsimport*classLevelThreeInline(NestedStackedInline):
model=LevelThreeextra=1fk_name='level'classLevelTwoInline(NestedStackedInline):
model=LevelTwoextra=1fk_name='level'inlines= [LevelThreeInline]
classLevelOneInline(NestedStackedInline):
model=LevelOneextra=1fk_name='level'inlines= [LevelTwoInline]
classTopLevelAdmin(NestedModelAdmin):
model=TopLevelinlines= [LevelOneInline]
admin.site.register(TopLevel, TopLevelAdmin)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-jsThen 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.jsCreate 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 djangoThen install the build tool:
pip install buildNext run the distribution build of the project:
python -m buildLastly, push the release to pypi
twine upload dist/*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