Code Monkey home page Code Monkey logo

django-admin-views's Introduction

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 links

Installation 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 redirect

from admin_views.admin import AdminViews

from example_app.models import TestModel

class TestAdmin(AdminViews):
    admin_views = (
                    ('Redirect to CNN', 'redirect_to_cnn'),
                    ('Go to revsys.com', 'http://www.revsys.com'),
        )

    def redirect_to_cnn(self, *args, **kwargs):
        return redirect('http://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

Author

Frank Wiles <[email protected]> <http://www.revsys.com>

Attribution

Blue link icon on direct URLs by http://www.doublejdesign.co.uk/

Admin view icon by http://www.fatcow.com/

django-admin-views's People

Contributors

akaihola avatar fcurella avatar frankwiles avatar jgastal avatar kostyaesmukov avatar mikeumus avatar ruimashita avatar toly avatar ulyssesv avatar vidz1979 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.