I'm doing a simple CRUD in Django for learning purposes, but I'm having a problem. When creating a view to add data to a schedule, the server returns the following error:
The view agenda.views.add does not return an HttpResponse object.
Here is the code for the "add" view I wrote:
def adiciona(request):
if request.method == "POST":
form = FormItemAgenda(request.POST, request.FILES)
if form.is_valid():
dados = form.cleaned_data
item = ItemAgenda(data=dados['data'], hora=dados['hora'], titulo=dados['titulo'], descricao=dados['descricao'])
item.save()
return render_to_response("salvo.html", {})
else:
form = FormItemAgenda()
return render_to_response("adiciona.html", {'form': form}, context_instance=RequestContext(request))
Set the routes in "urls.py" as follows:
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'agenda.views.lista'),
url(r'^adiciona/$', 'agenda.views.adiciona'),
)
I searched Google and the Django 1.6.x documentation and found no meaningful answers. How can I fix this error?