urls.py 是
(r'^when/$', 'when'),
(r'^media/$', 'media'),
(r'^followup/$', 'followup'),
模型.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 是
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))
我收到以下错误“
NoReverseMatch at /member/when/
Reverse for 'media' with arguments '()' and keyword arguments '{}' not found."
在views.py的以下行中
redirect_to = request.POST.get('next',
reverse('media')
)
模板是
<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 at /member/when/
'function' object has no attribute 'find'