GithubHelp home page GithubHelp logo

thaolt / django-admin-bootstrapped Goto Github PK

View Code? Open in Web Editor NEW

This project forked from django-admin-bootstrapped/django-admin-bootstrapped

0.0 2.0 0.0 489 KB

A Django admin theme using Twitter Bootstrap. It doesn't need any kind of modification on your side, just add it to the installed apps.

Home Page: http://www.codingnot.es/bootstrap-your-django-admin-in-3-minutes/

License: Apache License 2.0

django-admin-bootstrapped's Introduction

django-admin-bootstrapped

A Django admin theme using Twitter Bootstrap. It doesn't need any kind of modification on your side, just add it to the installed apps.

Requirements

  • Django 1.4.x.

Installation

  1. Download it from PyPi with pip install django-admin-bootstrapped
  2. Add 'django_admin_bootstrapped' into the INSTALLED_APPS list before 'django.contrib.admin'
  3. Have fun!

Goodies

Translate/change an application name with a template

With the default admin you can't change the application name, but django-admin-bootstrapped let you do it in a really easy way. Just create a file named admin_app_name.html into the application's template folder. Eg: myapp/templates/admin_app_name.html or project/templates/myapp/admin_app_name.html.

Add custom html to the change form of any model with a template

You can inject custom html on top of any change form creating a template named admin_model_MODELNAME_change_form.html into the application's template folder. Eg: myapp/templates/admin_model_mymodelname_change_form.html or project/templates/myapp/admin_model_mymodelname_change_form.html.

Inline sortable

You can add drag&drop sorting capability to any inline with a couple of changes to your code.

First, add a position field in your model (and sort your model accordingly), for example:

class TestSortable(models.Model):
    that = models.ForeignKey(TestMe)
    position = models.PositiveSmallIntegerField("Position")
    test_char = models.CharField(max_length=5)

    class Meta:
        ordering = ('position', )

Then in your admin.py create a class to handle the inline using the django_admin_bootstrapped.admin.models.SortableInline mixin, like this:

from django_admin_bootstrapped.admin.models import SortableInline
from models import TestSortable

class TestSortable(admin.StackedInline, SortableInline):
    model = TestSortable
    extra = 0

You can now use the inline as usual. The result will look like this:

This feature was brought to you by Kyle Bock. Thank you Kyle!

XHTML Compatible

Compatible with both html and xhtml. To enable xhtml for your django app add the following to your settings.py: DEFAULT_CONTENT_TYPE = 'application/xhtml+xml'

Generic lookups in admin

Generic lookups in admin

All that needs to be done is change the admin widget with either formfield_overrides like this:

from django_admin_bootstrapped.widgets import GenericContentTypeSelect

class SomeModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.ForeignKey: {'widget': GenericContentTypeSelect},
    }

Or if you want to be more specific:

from django_admin_bootstrapped.widgets import GenericContentTypeSelect

class SomeModelAdmin(admin.ModelAdmin):
    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name == 'content_type':
            kwargs['widget'] = GenericContentTypeSelect
        return super(SomeModelAdmin, self).formfield_for_dbfield(db_field, **kwargs)

If you decide on using formfield_overrides you should be aware of its limitations with relation fields.

This feature (and many more) was brought to you by Jacob Magnusson. Thank you Jacob!

Screenshots

Homepage

List view with filters in dropdown

Change form view

django-admin-bootstrapped's People

Contributors

riccardo-forina avatar jacobsvante avatar nsmgr8 avatar kwbock avatar kayluhb avatar intuxicated avatar adrianmester avatar ionelmc avatar ivanvotti avatar ndarville avatar ricw avatar

Watchers

James Cloos avatar Thao le 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.