From 9c10b1c3b60a64c780356784c5816eda8d8d9803 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 6 Oct 2020 13:17:28 +0200 Subject: [PATCH] first steps in generating project ids --- input/admin.py | 8 ++++++-- input/forms.py | 3 ++- input/models.py | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/input/admin.py b/input/admin.py index f7cfbb6..a2c1406 100644 --- a/input/admin.py +++ b/input/admin.py @@ -3,8 +3,12 @@ from django.contrib import admin # Register your models here. from .models import Project, HonoraryCertificate, Library, IFG #, ELitStip -admin.site.register([Project, - HonoraryCertificate, +@admin.register(Project) +class ProjectAdmin(admin.ModelAdmin): + fields = ('pid',) + readonly_fields = ('pid',) + +admin.site.register([HonoraryCertificate, Library, IFG, ]) diff --git a/input/forms.py b/input/forms.py index a0505d0..c96e1c2 100644 --- a/input/forms.py +++ b/input/forms.py @@ -10,7 +10,8 @@ class ProjectForm(ModelForm): class Meta: model = Project - exclude = ('pid',) + fields = '__all__' + # exclude = ('pid',) class VolunteerForm(ModelForm): diff --git a/input/models.py b/input/models.py index f335bd4..c44c17c 100644 --- a/input/models.py +++ b/input/models.py @@ -14,7 +14,11 @@ class Project(Volunteer): start = models.DateTimeField('start date') # contact = models.ForeignKey(Volonteer, on_delete = models.CASCADE, null = True) - pid = models.IntegerField(null=True) # automaticly generated + # pid = models.IntegerField(null=True) # automaticly generated + @property + def pid(self): + return "hurzel " + str(id) + def __str__(self): return self.name