Author: | Keryn Knight |
---|---|
Version: | 0.1.1 |
fakeinline
provides enough of the methods and attributes to trick the
Django Admin into displaying it when mounted as part of an inlines
declaration on a ModelAdmin. Where possible it does so without subclassing
real Django classes, as should be the case with Duck Typing.
The 2 necessary subclasses are the FakeInline
class itself, which must
subclass InlineModelAdmin
, and the model
attribute, FakeModel
which
must subclass Model
, but is unmanaged and abstract, so there is nothing
touching the database.
Release | Status |
---|---|
stable (0.1.1) | |
master |
The most interesting thing about the Django Admin is trying to bend it to my will. This is an example of my winning.
Because it's actually nicer to be able to wedge additional things into the admin,
without overriding the change_form.html
template on a per-model, per-app basis.
Beyond all considered reason, its on PyPI:
pip install django-fakeinline==0.1.1
Here's a simple way of putting the classic words Hello world onto a ModelAdmin:
class MyFormset(FakeFormset): # this probably works, but usually you'd point it at a template file. template = Template('{{inline_admin_formset.formset.get_data}}') def get_data(self, *a, **kw): return 'Hello world' class MyInline(FakeInline): formset = MyFormSet class MyAdmin(ModelAdmin): inlines = [MyInline]
Whilst a silly example, it demonstrates how one might encapsulate display data (charts, change history, etc) in a re-usable(ish) component for display on the change view.
There's a couple in fakeinline.tests
... just enough to verify it doesn't
raise an exception on GET or POST.
It's the FreeBSD. There's should be a LICENSE
file in the root of the repository, and in any archives.