title: Django /admin/ Page not found (404)
body: <p>I have the following error:</p>
  <pre><code>Page not found (404)
  Request Method:     GET
  Request URL:    http://127.0.0.1:8000/admin/
  Raised by:  nw.views.post_detail
  </code></pre>
  <p>But I can enter in example to <a href="http://127.0.0.1:8000/admin/nw/" rel="nofollow noreferrer">http://127.0.0.1:8000/admin/nw/</a></p>
  <p>And if I remove all <code>post_detail</code> functions/parts of the code then I can enter to <a href="http://127.0.0.1:8000/admin/" rel="nofollow noreferrer">http://127.0.0.1:8000/admin/</a> and it works, so something with this <code>post_detail</code> is wrong.</p>
  <p><strong>nw.views.post_detail:</strong></p>
  <pre><code>def post_detail(request, slug=None):
      instance = get_object_or_404(Post, slug=slug)
  
      context = {
          &quot;instance&quot;: instance,
      }
      return render(request, &quot;post_detail.html&quot;, context)
  </code></pre>
  <p><strong>urls.py:</strong></p>
  <pre><code>urlpatterns = [
      url(r'', include('nw.urls', namespace='posts')),
      url(r'^admin/', admin.site.urls),
  ]
  </code></pre>
  <p>and</p>
  <pre><code>urlpatterns = [
      url(r'^$', post_list, name='list'),
      url(r'^create/$', post_create),
      url(r'^(?P&lt;slug&gt;[\w-]+)/$', post_detail, name='detail'),
      url(r'^(?P&lt;slug&gt;[\w-]+)/edit/$', post_update, name='update'),
      url(r'^(?P&lt;slug&gt;[\w-]+)/delete/$', post_delete),
  ]
  </code></pre>
  <p><strong>post_detail.html:</strong></p>
  <pre><code>{% extends 'base.html' %}
  
  {% block head_title %}{{ instance.title }} | {{ block.super }}{% endblock head_title %}
  
  {% block content %}
      &lt;div class=&quot;instance&quot;&gt;
          &lt;h1&gt;{{ instance.title }}&lt;/h1&gt;
          &lt;div class=&quot;date&quot;&gt;{{ instance.published }}&lt;/div&gt;
          &lt;p&gt;{{ instance.text|linebreaksbr }}&lt;/p&gt;
  
          &lt;a href=&quot;https://www.facebook.com/sharer/sharer.php?u={{ request.build_absolute_uri }}&quot;&gt;
          Facebook
          &lt;/a&gt;
  
          &lt;a href=&quot;https://twitter.com/home?status={{ share_string }}%20{{ request.build_absolute_uri }}&quot;&gt;
          Twitter
          &lt;/a&gt;
  
          &lt;a href='https://plus.google.com/share?url={{ request.build_absolute_uri }}'&gt;google&lt;/a&gt;
  
  
          &lt;a href=&quot;https://www.linkedin.com/shareArticle?mini=true&amp;url={{ request.build_absolute_uri }}&amp;title={{ instance.title }}&amp;summary={{ share_string }}&amp;source={{ request.build_absolute_uri }}&quot;&gt;
          Linkedin
          &lt;/a&gt;
  
          &lt;a href=&quot;http://www.reddit.com/submit?url={{ request.build_absolute_uri }}&amp;title={{ share_string }}.&quot;&gt;Reddit&lt;/a&gt;
  
      &lt;/div&gt;
  
  {% endblock %}
  </code></pre>
  <p><strong>models.py:</strong></p>
  <pre><code>class Post(models.Model):
      author = models.ForeignKey('auth.User', default=1)
      title = models.CharField(max_length=200)
      slug = models.SlugField(unique=True)
      text = models.TextField()
      published = models.DateTimeField(auto_now=False, auto_now_add=True)
      updated = models.DateTimeField(auto_now=True, auto_now_add=False)
  
      def __str__(self):
          return self.title
  
      def get_absolute_url(self):
          return reverse(&quot;posts:detail&quot;, kwargs={&quot;slug&quot;: self.slug})
  
      class Meta:
          ordering = [&quot;-published&quot;]
  
  
  def create_slug(instance, new_slug=None):
      slug = slugify(instance.title)
      if new_slug is not None:
          slug = new_slug
      qs = Post.objects.filter(slug=slug).order_by(&quot;-id&quot;)
      exists = qs.exists()
      if exists:
          new_slug = &quot;%s-%s&quot; %(slug, qs.first().id)
          return create_slug(instance, new_slug=new_slug)
      return slug
  
  
  def pre_save_post_receiver(sender, instance, *args, **kwargs):
      if not instance.slug:
          instance.slug = create_slug(instance)
  
  
  pre_save.connect(pre_save_post_receiver, sender=Post)
  </code></pre>