Hi,
I'm hacking up a system to manage attendees at a camp.
I have a Person model (which might be better as a customer UserModel, still not sure).
There are multiple types of people - e.g. camp attendees, staff, supervisors etc.
Each person that is a camp attendee will also have an "Attendance" model associated with it (but other types of people will not have one).
If you think I'm better off modelling it a different way (e.g. abstract models, or some kind of inheritance), I'm open to suggestions.
This is my models.py fragment for Attendance:
class Attendance(models.Model):
person = models.OneToOneField(Person)
stream = models.ForeignKey(Stream)
subjects = models.ManyToManyField(Subject)
camp = models.ForeignKey(Camp)
This is my admin.py for Person:
class AttendanceInline(admin.TabularInline):
model = Attendance
class PersonAdmin(admin.ModelAdmin):
date_hierarchy = 'date_of_birth'
fieldsets = (
('Personal Details', {
'fields': ('first_name', 'middle_name', 'last_name', 'gender', 'date_of_birth', 'passport_number', 'working_with_children_check', 'photo', 'school', 'home_church')
}),
('Contact Details', {
'fields': ('email', 'phone_number', 'postal_address', 'home_address')
}),
('Other - think of a better name', {
'fields': ('serving_church', 'supervisor', 'year_12')
})
)
inlines = [
AttendanceInline,
]
admin.site.register(Person, PersonAdmin)
and my admin.py for Attendance:
class AttendanceAdmin(admin.ModelAdmin):
filter_horizontal = ['subjects']
When I edit a Person model, I want to have an inline for Attendance, and in that, use a filter_horizontal widget for "subjects".
However, currently, AttendanceAdmin on it's own has the filter_horizontal, but the inline does not.
This ticket seems to imply it should work:
hence I'm assuming I've wired up something wrong in the above - any thoughts?
Cheers,
Victor