first steps in generating project ids

This commit is contained in:
Benni Bärmann 2020-10-06 13:17:28 +02:00
parent 8db27707e1
commit 9c10b1c3b6
3 changed files with 13 additions and 4 deletions

View File

@ -3,8 +3,12 @@ from django.contrib import admin
# Register your models here. # Register your models here.
from .models import Project, HonoraryCertificate, Library, IFG #, ELitStip from .models import Project, HonoraryCertificate, Library, IFG #, ELitStip
admin.site.register([Project, @admin.register(Project)
HonoraryCertificate, class ProjectAdmin(admin.ModelAdmin):
fields = ('pid',)
readonly_fields = ('pid',)
admin.site.register([HonoraryCertificate,
Library, Library,
IFG, IFG,
]) ])

View File

@ -10,7 +10,8 @@ class ProjectForm(ModelForm):
class Meta: class Meta:
model = Project model = Project
exclude = ('pid',) fields = '__all__'
# exclude = ('pid',)
class VolunteerForm(ModelForm): class VolunteerForm(ModelForm):

View File

@ -14,7 +14,11 @@ class Project(Volunteer):
start = models.DateTimeField('start date') start = models.DateTimeField('start date')
# contact = models.ForeignKey(Volonteer, on_delete = models.CASCADE, null = True) # 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): def __str__(self):
return self.name return self.name