Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/koleror/django-admin-views
Easily link custom admin views and direct URLs into the Django admin
https://github.com/koleror/django-admin-views
Last synced: 5 days ago
JSON representation
Easily link custom admin views and direct URLs into the Django admin
- Host: GitHub
- URL: https://github.com/koleror/django-admin-views
- Owner: koleror
- License: bsd-3-clause
- Created: 2012-07-07T17:41:34.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-04-21T22:32:43.000Z (almost 2 years ago)
- Last Synced: 2025-01-18T19:56:08.834Z (12 days ago)
- Language: Python
- Size: 234 KB
- Stars: 187
- Watchers: 11
- Forks: 33
- Open Issues: 12
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- stars - koleror/django-admin-views - Easily link custom admin views and direct URLs into the Django admin (Python)
- stars - koleror/django-admin-views - Easily link custom admin views and direct URLs into the Django admin (Python)
README
Overview
========While "the admin is not your app", it is often useful to be able to easily add
a bit of functionality to the admin for internal staff or other internal users
that are tech savvy enough to use the admin.There are several third party project such as
`AdminPlus `_, but they require the
user to redefine the Admin.site object. This is fine for developers who are
setting up a Django project, but not ideal for developers who are writing
third party tools for other developers to use in their projects.django-admin-views attempts to solve this by simply overriding the admin
templates to provide two features:1. Easily define custom admin views and link them on the admin pages
2. Easily add in external URL linksInstallation Steps
==================1. ``pip install django-admin-views``
2. Add ``admin_views`` to ``INSTALLED_APPS`` in your ``settings.py`` before admin site, i.e. ``django.contrib.admin``
If you are using a custom Admin Site, you'll need to configure the ``ADMIN_VIEWS_SITE`` setting to point to your admin site instance::
ADMIN_VIEWS_SITE = 'myproject.admin.admin_site'
Usage
=====All of this magic happens in your model's admin definition. You simply subclass your
admin from ``AdminViews`` instead of the standard ``admin.ModelAdmin``.
In this example we have a custom view that does nothing but redirect the user to CNN
and a direct URL link that goes to my company's homepage::from django.contrib import admin
from django.shortcuts import redirectfrom admin_views.admin import AdminViews
from example_app.models import TestModel
class TestAdmin(AdminViews):
admin_views = (
('Redirect to CNN', 'redirect_to_cnn'),
('Go to google.com', 'https:/google.com'),
)def redirect_to_cnn(self, *args, **kwargs):
return redirect('https://www.cnn.com')admin.site.register(TestModel, TestAdmin)
These will now show up in the admin below the usual Django admin model CRUD interfaces
for `example_app` with a couple of different icons to distinquish between custom admin
views and a direct URL link.With this third-party developers need only instruct their users to install their app
and ``django-admin-views``.Hope you find it useful and as always feedback is certainly welcome.
Screenshot
==========.. image:: https://raw.githubusercontent.com/koleror/django-admin-views/master/screenshots/admin.png
Author
======
Frank Wiles [email protected]Maintainer
==========
Hugo Defrance [email protected]