Re: Saving test user as a foreign key in unit tests
Problem solved. Within my view I needed use the following:
def create_tasting(request):
if request.method =='POST':
form = TastingForm(request.POST)
if form.is_valid():
obj = form.save(commit=False)
obj.author = request.user
obj.save()
return HttpResponseRedirect('/tastings/')
else:
form = TastingForm()
return render_to_response('tastings/create.html', {
'form': form
}, context_instance=RequestContext(request))
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Q6I4oSuCsTIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home