Can you post/submit to the same view named in urls.conf?

14 views
Skip to first unread message

miguel vfx

unread,
Apr 11, 2017, 7:09:03 AM4/11/17
to Django users

url(r'^register/(?P<student_id>[-\w]+)/$', rrs_views.rrs_register_student, name="rrs_register_student"),

 <form action="{% url 'rrs_register_search' %}" method="post">

 def rrs_register_student(request, student_id='', section=''):

Good day, I suspect that I'm doing something wrong here. What I wanted to achieve is...
  • When the page is loaded, it will render a template with a form.
  • When the page is loaded while the form is submitted (if request.method == 'POST'), then it will process the form.
So basically, the form action is pointing at the same view. There will be two different sets of commands: for get/url and for post.

Here's the error I'm getting:

NoReverseMatch

Reverse for 'rrs_register_student' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['rrs/register/(?P<student_id>[-\\w]+)/$']
 
Thank you in advance.

ludovic coues

unread,
Apr 11, 2017, 7:34:51 AM4/11/17
to django...@googlegroups.com
You failed to post the bare minimum information required to debug your problem.

Error of type NoReverseMatch have close to nothing to do with the function.
So the line `def rrs_register_student` is not useful.

The message with the error clearly state that no reverse where found
for rrs_register_student. The piece of html you posted try to reverse
rrs_register_search.
So this piece of html is not useful.

About your problem, the error message say an url matching the route
name was found. That url take an argument, student_id. But you didn't
specify any argument to your reverse function.

Good luck fixing your problem.
If you want more help, bring more information.
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@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/c50973bf-08f2-4d9b-8d94-c65008bb2628%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Ludovic Coues
+33 6 14 87 43 42
Reply all
Reply to author
Forward
0 new messages