This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Django ModelAdmin field syntax simplifier.

Common django admin field customization syntax for looks like this.

class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')

    def human_size(self, obj):
        return filesizeformat(obj.size)
    human_size.short_description = 'size'
    human_size.admin_order_field = 'size'

This lib allows allows to sorten it and make it reusable.

class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')
    human_size = AdminField('size', filesizeformat)

Inheritance

You can create some reusable fields, for multipy usage.

class AdminSizeField(AdminFieldBase):
    DEFAULT_FIELD = 'size'
    method = staticmethod(human_size)


class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')
    human_size = AdminSizeField()

Attributes

By default, ‘short description’ and ‘admin order field’ will be taken from the field name. But you can overide it by kwargs.

class FileAdmin(ModelAdmin)
    list_display = ('name', 'human_size')
    human_size = AdminField('size', filesizeformat,
        short_description='real size', allow_tags=True)

Foreign keys

By default ModelAdmin doesn’t allow you to use foreign keys in list_display. Feel free to do it with AdminField. It will atomaticaly optain description and sort field.

class UserFileAdmin(ModelAdmin)
    list_display = ('name', 'file__size')
    file__size = AdminField('file__size', filesizeformat)

Don’t forget to select related model.

class UserFileAdmin(ModelAdmin)
    select_related = ['file']
    list_display = ('name', 'file__size')
    file__size = AdminField('file__size', filesizeformat)

    def queryset(self, request):
        return super(AdminModelSelectRelated, self).queryset(request).select_related(*self.select_related)
Release History

Release History

0.0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-admin-field-0.0.1.tar.gz (1.9 kB) Copy SHA256 Checksum SHA256 Source Apr 29, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting