Hi,

I have the following view function that I need to implement as a class 
based view:

def admin_race_events(request, year, slug):

    # cruft based on year and slug skipped - getting abstracted into an 
inherited class
    # raceday is a model

    categories_in_event = raceday.categories_in_order()

    formset_cats_in_events = 
modelformset_factory(model=racereg_models.CategoriesInEvent,
                                                  
form=racereg_forms.CatsInEventForm,
                                                  extra=0,
                                                  
formset=racereg_forms.CatsInEventFormSet)

    if request.POST:
        formset_instance = formset_cats_in_events(request.POST, 
queryset=categories_in_event)
        if formset_instance.is_valid():
            formset_instance.save()

            messages.success(request, "Events updated.")
            return redirect(cancel_link)
        else:
            messages.error(request, "Invalid data entered - please check the 
form.")
    else:
        formset_instance = formset_cats_in_events(queryset=categories_in_event)

    return render(request, 'race_day_admin/events.html', locals())


This seems like a candidate where I would use an UpdateView as my starting 
point 
(https://docs.djangoproject.com/en/1.9/ref/class-based-views/generic-editing/#django.views.generic.edit.UpdateView).

What I am not seeing is how the modelformset_factory would fit with using 
UpdateView. Any recommendations for how to proceed?

Thanks,
Richard Brockie


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/77e1f6ed-bd5d-4cbf-859c-202d3b09d1e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to