1

I have a simple form where a user enters some text and on submission an operation is carried out and the results returned to the user. For example the user enters a bunch of text and on submission a page is displayed with the sentence count.

views.py

from django.core.urlresolvers import reverse_lazy, reverse
from django.http import HttpResponseRedirect
from django.views.generic import ListView, CreateView, DetailView


class CreateEntry(CreateView):
    model = Entryt
    fields = ['text']


    def form_valid(self, form):
        return HttpResponseRedirect(reverse('app:result'))


class ResultView(DetailView):
    model = Entryt
    context_object_name = 'fl'
    template_name = 'flesch/result.html'

def get_queryset(self): return Entryt.objects.get(pk='entryt_id')

project url contains this for the app

url(r'^flesch/', include('flesch.urls', namespace='app')),

app urls.py

from django.conf.urls import url
from .views import ResultView, CreateEntry

urlpatterns = [

    url(r'^$', CreateEntry.as_view(), name='create'),
    url(r'^(?P<pk>[0-9]+)/$', ResultView.as_view(), name='result'),
]

error message when a form is submitted

NoReverseMatch at /flesch/
Reverse for 'result' with arguments '()' and keyword arguments '{}'           

not found. 1 pattern(s) tried: ['flesch/(?P<pk>[0-9]+)/$']

Are my on the right path on how to achieve this or how do I fix this?

0 Answers0