django - Reverse for 'media' with arguments '()' and keyword arguments '{}' not found -
urls.py is
(r'^when/$', 'when'), (r'^media/$', 'media'), (r'^followup/$', 'followup'),
models.py
class report(models.model): user = models.foreignkey(user, null=false) incident_number = models.charfield('incident number', max_length=100) device_id = models.charfield('device id', max_length=100) app_uuid = models.charfield('unique app id', max_length=100) created_date_time = models.datetimefield('created') manual_date_time = models.datetimefield('another time', null=true, blank=true) sent_date_time = models.datetimefield('sent')
views.py is
def when(request): if request.method == 'post': reportform = reportform(data=request.post) if reportform.is_valid(): log.debug("test:%s",reportform) report = reportform.save(commit=false) report.user = request.user redirect_to = request.post.get('next', reverse('media') ) return httpresponseredirect(media) else: pass else: reportform = reportform() return render_to_response('incident/when.html',{ 'newreport_menu': true, 'form': reportform, }, context_instance=requestcontext(request))
i getting below error "
noreversematch @ /member/when/ reverse 'media' arguments '()' , keyword arguments '{}' not found."
in following line in views.py
redirect_to = request.post.get('next', reverse('media') )
template is
<form action="/member/when/" method="post"> {% csrf_token %} {{ form.manual_date_time }} <p id=ir-nextbutn><a href="{% url incident.views.media %}"> {% include "buttons/next.html" %}</form> attributeerror @ /member/when/ 'function' object has no attribute 'find'
you need name urls
url(r'^when/$', 'when', name='when'), url(r'^media/$', 'media', name='media'), url(r'^followup/$', 'followup', name='followup'),
or avoid conflicting url names can prefix app's name.
url(r'^when/$', 'when', name='app_name_when'), url(r'^media/$', 'media', name='app_name_media'), url(r'^followup/$', 'followup', name='app_name_followup'),
obviously replace app_name actual name of app.
you can update template
{% url incident.views.media %} # changes to: {% url 'media' %}
Comments
Post a Comment