Django urls regex is not working
Question: I have an issue with Django's urls.py's regex part. I want to show a page for
every entry users entered. My views.py looks like:

    
    
    def tekent(request):
        tumentry = Entry.objects.get(id=id)
    
        return render_to_response("baslik/tekentry.html", locals(), context_instance=RequestContext(request))
    
    
    def tek(request, slug):
        basliklar = Baslik.objects.filter(active=True).order_by('-updated')
        baslik = Baslik.objects.get(slug=slug)
        entryler = baslik.entry_set.all()
        form2 = EntryForm(request.POST or None)
    
        if form2.is_valid():
            entry = form2.save(commit=False)
            entry.baslik = baslik
            entry.user = request.user
            entry.save()
            return HttpResponseRedirect('/entry/%s'%(entry.id))
    
    
        return render_to_response("baslik/tek.html", locals(), context_instance=RequestContext(request))
    

My main urls.py(not the app's) looks like this:

    
    
    from baslik import *
    urlpatterns = patterns('',
    url(r'^entry/(?P<Entry.id>)/$', 'tekent', name = "tek_entry"),
    )
    

and when I add an entry on web browser, it raises an error like this:

    
    
    DoesNotExist at /baslik/entry4/
    Baslik matching query does not exist.
    Request Method: GET
    Request URL:    http://127.0.0.1:8000/baslik/entry4/
    Django Version: 1.6.5
    Exception Type: DoesNotExist
    Exception Value:    
    Baslik matching query does not exist.
    Exception Location: /Users/malisit/Django/sozluk/lib/python2.7/site-packages/django/db/models/query.py in get, line 310
    Python Executable:  /Users/malisit/Django/sozluk/bin/python
    

What should I do to fix this up? Thanks.


Answer: Try `url(r'^entry/(?P<id>\d+)/$', 'tekent', name = "tek_entry"),`

Why don't you use class based views?
[DetailView](https://docs.djangoproject.com/en/1.6/ref/class-based-
views/generic-display/#detailview) is really handy for such things.

