Gustavo Picon is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

tabo / django-treebeard

Efficient tree implementations for Django 1.0+ :: https://tabo.pe/projects/django-treebeard/

Clone this repository (size: 602.0 KB): HTTPS / SSH
hg clone https://bitbucket.org/tabo/django-treebeard
hg clone ssh://hg@bitbucket.org/tabo/django-treebeard
Branch
1.6.X
import datetime

from django.contrib import admin
from treebeard.admin import TreeAdmin

from tbexample.models import MP_Post, AL_Post, NS_Post


class TreeExampleAdmin(TreeAdmin):
    def save_form(self, request, form, change):
        if not change:
            form.cleaned_data['created'] = datetime.datetime.now()
        return form.save(commit=False)


class MP_Admin(TreeExampleAdmin):
    pass


class AL_Admin(TreeExampleAdmin):
    pass


class NS_Admin(TreeExampleAdmin):
    pass


admin.site.register(MP_Post, MP_Admin)
admin.site.register(AL_Post, AL_Admin)
admin.site.register(NS_Post, NS_Admin)