I figured it out. I had a namespaced url so it needed:

return HttpResponseRedirect(reverse('requestform:registrant_add', 
kwargs={'app_id': obj.id}))

On Monday, January 13, 2014 12:22:59 PM UTC-5, Brad Rice wrote:
>
> I have a mulit-page form I am building. I get the start page to enter the 
> data for the application, validate and save. When I try using reverse to 
> move to the next page I get this error:
>
> NoReverseMatch at /requestform/start/Reverse for 'registrant_add' with 
> arguments '()' and keyword arguments '{'app_id': 11}' not found.
>
> I have this url in my urls.py
>
> url(r'^step1/(?P<app_id>\d+)/$, RegistrantCreate.as_view(), 
> name="registrant_add"),
>
> I am trying to call the view this way:
>
> class ApplicationCreate(CreateView):
>     model = Application
>     form_class = ApplicationForm
>     slug_field = 'created_by'
>     template_name = 'requestform/start_form.html'
>
>     @method_decorator(login_required)
>     def dispatch(self, *args, **kwargs):
>         return super(ApplicationCreate, self).dispatch(*args, **kwargs)
>
>
>     def form_valid(self, form):
>         obj = form.save(commit=False)
>         obj.created_by = self.request.user
>         obj.created = datetime.datetime.today()
>         obj.modified = datetime.datetime.today()
>         obj.save()
>         return HttpResponseRedirect(reverse('registrant_add', 
> kwargs={'app_id': obj.id}))
>
> Why doesn't django recognize the named url 'registrant_add' and redirect 
> to it?
>
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c8908fe0-1b86-4dcb-a977-cb4a6c999186%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to