How to use the django.contrib.admin.site.register function in Django

To help you get started, we’ve selected a few Django examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ninuxorg / nodeshot / nodeshot / admin.py View on Github external
'change': False,
            'has_delete_permission': False,
            'has_change_permission': True,
            'has_absolute_url': False,
            'opts': self.model._meta,
            'original': node,
            'save_as': False,
            'show_save': True,
            #'root_path': self.admin_site.root_path,
        }, context_instance=RequestContext(request))

admin.site.register(Node, NodeAdmin)
admin.site.register(Device, DeviceAdmin)
admin.site.register(Interface, InterfaceAdmin)
admin.site.register(Hna)
admin.site.register(Link, LinkAdmin)
admin.site.register(Statistic, StatisticAdmin)
admin.site.register(Contact, ContactAdmin)

# UserProfile

class UserProfileInline(admin.StackedInline):
	model = UserProfile

class UserProfileAdmin(UserAdmin):
    inlines = [UserProfileInline]

admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
github enigmagroup / enigmabox-openwrt / webinterface / files / root / opt / enigmabox / webinterface / app / admin.py View on Github external
from app.models import *
from django.contrib import admin

admin.site.register(Address)
admin.site.register(Country)
admin.site.register(Option)
admin.site.register(Peering)
github migasfree / migasfree / system / admin.py View on Github external
from migasfree.system.models import FaultDef
from migasfree.system.models import Query
from migasfree.system.models import Schedule
from migasfree.system.models import ScheduleDelay
from migasfree.system.models import DeviceManufacturer
from migasfree.system.models import DeviceType
from migasfree.system.models import DeviceModel
from migasfree.system.models import DeviceConnection
from migasfree.system.models import Device
from migasfree.system.models import Checking
from migasfree.system.models import AutoCheckError
from migasfree.system.models import Message
from migasfree.system.models import Update


admin.site.register(DeviceType)
admin.site.register(DeviceManufacturer)
admin.site.register(DeviceConnection)
admin.site.register(UserProfile)
admin.site.register(AutoCheckError)


def user_version(user):
    user_id=user.id
    try:
        version=UserProfile.objects.get(id=user_id).version.id
    except:
        version=None
    return version


class VersionAdmin(admin.ModelAdmin):
github burke-software / schooldriver / ecwsp / schedule / admin.py View on Github external
class MarkingPeriodAdmin(admin.ModelAdmin):
    inlines = [DaysOffInline]
    fieldsets = (
        ('', {
            'fields': ('active','name','shortname',('start_date','end_date'),
                       'grades_due','school_year','show_reports',
                       'school_days','weight'),
        },),
        ('Change active days', {
            'classes': ('grp-collapse grp-closed',),
            'fields': ('monday','tuesday','wednesday','thursday',
                       'friday','saturday','sunday',),
        },),
    )
admin.site.register(MarkingPeriod, MarkingPeriodAdmin)

admin.site.register(Period)

admin.site.register(Location)

admin.site.register(OmitCourseGPA)

admin.site.register(OmitYearGPA)

admin.site.register(Award)
github mozilla / source / source / people / admin.py View on Github external
field.widget.attrs['style'] = 'width: 30em;'
        return field

class OrganizationAdmin(AdminImageMixin, admin.ModelAdmin):
    save_on_top = True
    prepopulated_fields = {'slug': ('name',)}
    list_filter = ('is_live',)
    search_fields = ('name', 'description',)
    fieldsets = (
        ('', {'fields': (('name', 'slug'), ('is_live', 'show_in_lists'), 'email', 'twitter_username', 'github_username', ('github_repos_num', 'github_gists_num'), 'homepage', 'logo', 'description',)}),
        ('Location', {'fields': ('address', ('city', 'state',), 'country',)}),
    )
    inlines = [OrganizationLinkInline,]

admin.site.register(Person, PersonAdmin)
admin.site.register(Organization, OrganizationAdmin)
github foreveryh / django-excel-import / cityapp / apps / city_viewer / admin.py View on Github external
class ShortURLAdmin (GuardedModelAdmin):
    list_display = ('short', 'url', 'usage_count', 'short_url', 'created_at')

    def short(self, obj):
        return obj.to_base62()
    short.short_description = '短链标示'

    def short_url(self, obj):
        return settings.SITE_BASE_SHORTURL + obj.to_base62() + '/'
    short_url.short_description = '短链接'


admin.site.register(Area, AreaAdmin)
admin.site.register(Place, PlaceAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(Picture, PictureAdmin)
admin.site.register(TripTip, TripTipAdmin)
admin.site.register(OfflineMap, OfflineMapAdmin)
admin.site.register(APPInfo, APPInfoAdmin)
admin.site.register(APPReview, APPReviewAdmin)
admin.site.register(APPDevice, APPDeviceAdmin)
admin.site.register(Channel, APPChannelAdmin)
admin.site.register(ClickStat, ClickStatAdmin)
admin.site.register(ASAccount, ASAccountAdmin)
admin.site.register(ShortURL, ShortURLAdmin)
github fsi-tue / fachschaftsempfaenger / fachschaftsempfaenger / admin.py View on Github external
class FoodAdmin(admin.ModelAdmin):
    search_fields = ['meal']
    list_display = ['meal', 'price']


class AdvertisementAdmin(admin.ModelAdmin):
    list_display = ['id', 'start_date', 'end_date', 'image']


class MemberAdmin(admin.ModelAdmin):
    list_display = ['first_name', 'last_name']
    ordering = ['last_name']


admin.site.register(Food, FoodAdmin)
admin.site.register(Menu)
admin.site.register(Advertisement, AdvertisementAdmin)
admin.site.register(Member, MemberAdmin)
github SpreadBand / django-badges / badges / admin.py View on Github external
from django.contrib import admin

from badges.models import Badge, BadgeToLaureate

class BadgeAdmin(admin.ModelAdmin):
    fields = ('icon',)
    list_display = ('id','level')

admin.site.register(Badge, BadgeAdmin)
admin.site.register(BadgeToLaureate)
github Faisal-Manzer / django-paytm-checkout / paytm / admin.py View on Github external
@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
    list_display = ('order_id', 'txn_id', 'amount', 'status')

    def has_change_permission(self, request, obj=None):
        return False

    def has_delete_permission(self, request, obj=None):
        return True

    def has_add_permission(self, request):
        return False


admin.site.register(Item)