SHARE
TWEET

Untitled

a guest Jun 19th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.contrib import admin
  2. from articles.models import Article
  3. from articles.models import Sujet
  4. from django.contrib.auth.models import User
  5.  
  6.  
  7. class SujetAdmin(admin.ModelAdmin):
  8.     fieldsets = [
  9.                  (None, {'fields': ['titre', 'logo']})
  10.                 ]
  11.  
  12.     list_display = ['titre', 'logo']
  13.     search_fields = ['titre']
  14.     list_filter = ['titre']
  15.  
  16.  
  17. admin.site.register(Sujet, SujetAdmin)
  18.  
  19.  
  20. class ArticleAdmin(admin.ModelAdmin):
  21.     auteur = models.CharField(max_length=50, choices= User.username)
  22.  
  23.     fieldsets = [
  24.                  ('Redaction', {'fields': ['sujet', 'titre', 'article', 'date', 'auteur']}),
  25.                  ('Option', {'fields': ['image'], 'classes': ['collapse']}),
  26.                 ]
  27.  
  28.     list_display = ['sujet', 'titre', 'article', 'auteur', 'date']
  29.     search_fields = ['sujet', 'titre', 'article', 'auteur', 'date']
  30.     list_filter = ['sujet', 'titre', 'article', 'auteur', 'date']
  31.  
  32.  
  33. admin.site.register(Article, ArticleAdmin)
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top