title: Django URL regex complication
body: <p>I am having trouble defining the URLs for my django app.</p>
  
  <p>I want it so that when I type,</p>
  
  <p><a href="http://example.com/post/3" rel="nofollow">http://example.com/post/3</a>        :: I can read a post</p>
  
  <p><a href="http://example.com/post/3/edit" rel="nofollow">http://example.com/post/3/edit</a>   :: I can edit a post</p>
  
  <p>At the moment, I defined it like the following:</p>
  
  <pre><code>url(r'^post/(?P&lt;id&gt;\d+)/edit/$',
      'board.views.edit_post',
      name='edit_post'),
  
  url(r'^post/(?P&lt;id&gt;\d+)',
      'board.views.view_post',
      name='view_post'),
  </code></pre>
  
  <p>However this does not seem to work because when I click on my "edit" link which links to </p>
  
  <p>"/post/{{ post.id }}/edit"</p>
  
  <p>I get the intended url in my address bar but am not taken to the edit view...</p>
  
  <p>===================================</p>
  
  <p>--EDIT--</p>
  
  <pre><code>@login_required
  def edit_post(request, id):
      if id:
          post = get_object_or_404(Post, id=id)
          if post.owner_user != request.user:
              return HttpResponseForbidden()
  #     else:
  #         post = Post(owner_user=request.user)
  
      if request.POST:
          form = PostEditForm(request.POST)
          if form.is_valid():
              form.save() 
  
              return HttpResponseRedirect('')
      else:
          form = PostEditForm()
  
      return (request,'edit_post.html', {
          'form': form})
  </code></pre>
  
  <p>And </p>
  
  <pre><code>def view_post(request, id):   
      #context = RequestContext(request)
      if request.method == 'POST':
          form = CommentForm(request.POST)
          if form.is_valid():
              form = form.save(commit=False)
              form.owner = request.user
              form.parent_post = get_object_or_404(Post, id=id)
              form.comment_type = 0
              form.save()
  
              return HttpResponseRedirect('')
      else:
          form = CommentForm()
  
      return render(request,'view_post.html', {
          #'comment' : get_object_or_404(Comment, parent_post = id),
          'comment': Comment.objects.filter(parent_post=id),
          'form': form,
          'post': get_object_or_404(Post, id=id)
      })
  </code></pre>