Is it possible to manually add field entries to an object that has been created with the generic view?
Eg,
from django.views.generic.create_update import create_object
def create_thing(request):
queryset = Things.objects.all()
#Somehow pass something to tell the view to
#assign Thing.author=request.user...
return create_object(
request,
queryset,
form_class = ThingForm,
template_name = 'thing_template.html',
)
Ta!
Sorry, no. You’ll have to write your own view.
Here’s the source – you can see that there’s no callback or anything, and nothing that gets passed both the request (so you can access request.user) and the new_object that you could possibly override to do the assignment.