Dynamic initial values for a Django Model
How would i go about prepopulating a field in the Wagtail Admin UI with HTTP GET parameters? I have seen some solutions using the deprecated contrib.ModelAdmin, but have not really found something using the new ModelViewSet.
My simplified use case would be a simple calender in the Admin UI (using some javascript calender like fullcalandar.js) where i would create a new Event by dragging a timeframe and having the browser visit an url like /admin/event/new?start=startdate&end=enddate showing the Event Form with the start and end fields being prepoulated by the timeframe.
I have the following model
class Event(models.Model):
title = models.CharField(max_length=255)
[...]
class EventOccurrence(Orderable):
event = ParentalKey(Event, on_delete=models.CASCADE, related_name='event_occurrence')
start = DateTimeField()
end = DateTimeField()
So far i have tried to use an Custom Form Class inherting from WagtailAdminModelForm, which works nicely for the prepopulating, but i have no way to access the request object to fetch the GET paramters.
Helpful AIs would like me to use the deprecated ModelAdmin or inject some javascript to prepopulate the fields on the frontend. My personal hail mary would be to create the event via an API and the just refer the user to the freshly created event, but i would like to avoid that :) I found some references to a CreatePageView, but this does not seem to exist anymore in modern Wagtail.
I have the slight suspicion that there is a more straightforward solution. Something like creating my own route and just shadowing and overwriting some basis class and methods. But my wagtail/django-fu is definitely not strong enough to figure out where to start).
Maybe somebody can at least point me in the right direction? Or maybe even has an idea, how i could use a ChooserWidget for the same task? Or at least a modal embedding the form with the prepopulated fields.