Browse Source

first steps in generating project ids

master
Benni Baermann 4 years ago
parent
commit
9c10b1c3b6
3 changed files with 13 additions and 4 deletions
  1. +6
    -2
      input/admin.py
  2. +2
    -1
      input/forms.py
  3. +5
    -1
      input/models.py

+ 6
- 2
input/admin.py 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,
HonoraryCertificate,
@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
fields = ('pid',)
readonly_fields = ('pid',)
admin.site.register([HonoraryCertificate,
Library, Library,
IFG, IFG,
]) ])

+ 2
- 1
input/forms.py 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):

+ 5
- 1
input/models.py 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

Loading…
Cancel
Save