Snippet List
It's an update of snippet [https://djangosnippets.org/snippets/1376/](https://djangosnippets.org/snippets/1376/) to work with Django 1.8. With this piece of code, you can override admin templates without copy or symlink files. Just write your template and extend the target.
This combination of settings.py admin_reorder_tag.py and admin/base_site.html gives you the ability to define custom ordering for the apps and models in the admin app.
1. Add the setting ADMIN_REORDER to your settings.py as a tuple with each item containing a tuple of the app name and a tuple of the models within it, all defining the ordering to apply.
2. Drop the template tag code into admin_reorder_tag.py and put this into a templatetag package in one of your installed apps.
3. Drop the template code into your templates directory as admin/base_site.html
This Snippet allows for your project's apps names to be displayed as you want in the Admin, including translations.
The lists of apps and languages are created from your settings.py file.
**How to use**
1st part:
- Create a application called 'apps_verbose' in you project with the models.py and admin.py showed here
- Create a folder inside it with named 'templatetags' with the verbose_tags.py file inside it.
- Add this app to installed apps in your settings.py
- If you change this app name, dont forget to correct the imports.
2nd part:
- Create a folder named 'admin' in your templates folder and copy the following files form your /django/contrib/admin/templates/admin/ folder.
- /app_index.html
- /base.html
- /change_form.html
- /change_list.html
- /delete_confirmation.html
- /delete_selected_confirmation.html
- /index.html
- /object_history.html
- Make the necessary changes in each file, like shown here.
3rd part:
- Create translations in the Admin and enjoy.
- template
- django
- admin
- i18n
- python
- tags
- html
- app
- translation
You can use this template loader if you want to use template specifically from one app. Useful mainly in overriding admin templates - just make your own `admin/change_form.html` and have it extend `admin:admin/change_form.html` withou creating any symlinking or copying django admin's templates to alternate location.
Part of the [ella project](http://www.ellaproject.cz/).
Save this as conf.py in the app's directory. Now you can do `from myapp.conf import settings`.
You can access from the imported object every item of your settings.py including the default settings of myapp. Though you don't have to define every setting in settings.py you use in your app. Now you can ommit annoying try...except statements to define defaults directly in the code.
This is modification of Django's original adminapplist template tag. You can move your models from one app to other or completely hide them with this mod.
Copy django_dir/contrib/admin/templates/admin/index.html file to your templates/admin folder, open it, then change {% load adminapplist %} to {% load custom_adminapplist %} (or whatever you named the templatetag file)
After that, write your regrouping schema to settings.py file like this;
UPDATED, now using tupples instead of dicts in APP_SCHEMA to make it more DRY.
`
APP_SCHEMA=[
(
['Model','List'],
'From App',
'To App',
),
(
['FlatPage'],
'Flatpages',
'Site Content',
),
(
['Product']
'Product',
'Shop',
),
(
['Site']
'Sites',
#We are hiding Site model by not defining a target.
),
]
`
- templatetag
- models
- admin
- app
8 snippets posted so far.