From 23b28e0406da14ac1cf0627a97a40e5ec757d7f4 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 6 Oct 2020 14:55:46 +0200 Subject: [PATCH] project id displayed in admin --- input/admin.py | 14 ++++++++++++-- input/models.py | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/input/admin.py b/input/admin.py index a2c1406..d9282b1 100644 --- a/input/admin.py +++ b/input/admin.py @@ -3,12 +3,22 @@ from django.contrib import admin # Register your models here. from .models import Project, HonoraryCertificate, Library, IFG #, ELitStip +# @admin.register(Project) +# class ProjectAdmin(admin.ModelAdmin): +# #fields = ('pid',) +# readonly_fields = ('pid',) +# # list_display =('pid',) +# def __init__(self, *args, **kwargs): +# super().__init__(*args, **kwargs) +# self.fields = super().get_all_field_names() + 'pid' +# return self + @admin.register(Project) class ProjectAdmin(admin.ModelAdmin): - fields = ('pid',) readonly_fields = ('pid',) -admin.site.register([HonoraryCertificate, +admin.site.register([ + HonoraryCertificate, Library, IFG, ]) diff --git a/input/models.py b/input/models.py index c44c17c..8937d92 100644 --- a/input/models.py +++ b/input/models.py @@ -17,9 +17,14 @@ class Project(Volunteer): # pid = models.IntegerField(null=True) # automaticly generated @property def pid(self): - return "hurzel " + str(id) - + pid = "hurzel " + self.get_pk + print(pid) + return pid + # def save(self,*args,**kwargs): + # self.pid = + # super().save(*args,*kwargs) + # def __str__(self): return self.name