title: Django: ValueError invalid literal for int() with base 10
body: <p>I have two models <strong>Post</strong> and <strong>Category</strong>.</p>
  
  <p><em>models.py</em></p>
  
  <pre><code>class Post(models.Model):
      title = models.CharField(max_length=100, unique=True)
      slug = models.SlugField(max_length=100, unique=True)
      content = models.TextField()
      posted = models.DateField(db_index=True, auto_now_add=True)
      category = models.ForeignKey('blog.Category')
  
      def __unicode__(self):
          return '%s' % self.title
  
  
  class Category(models.Model):
      title = models.CharField(max_length=100, db_index=True)
      slug = models.SlugField(max_length=100, db_index=True)
  
      def __unicode__(self):
          return '%s' % self.title
  </code></pre>
  
  <p><em>views.py</em></p>
  
  <pre><code>def post_view(request, slug, slug1):
      return render(request, 'post_view.html', {
          'post': get_object_or_404(Post, category=slug, slug=slug1)
      })
  
  
  def category_view(request, slug):
      category = get_object_or_404(Category, slug=slug)
      return render(request, 'cat_view.html', {
          'category': category,
          'posts': Post.objects.filter()[:5]
      })
  </code></pre>
  
  <p><em>urls.py</em></p>
  
  <pre><code>url(r'category/(?P&lt;slug&gt;[-\w]+)/$', views.category_view, name='cat_view'),
      url(r'category/(?P&lt;slug&gt;[-\w]+)/(?P&lt;slug1&gt;[-\w]+)/$', views.post_view, name='post_view'),
  </code></pre>
  
  <p>and finally the templates
  <em>category.html</em></p>
  
  <pre><code>{% block content %}
  
      {% if posts %}
          &lt;ul&gt;
              {% for post in posts %}
                  &lt;li&gt;&lt;a href="{% url 'blog:post_view' slug=post.category slug1=post.slug %}"&gt;
                      {{ post.title }}&lt;/a&gt;&lt;/li&gt;
              {% endfor %}
          &lt;/ul&gt;
      {% else %}
          &lt;p&gt;There are no post yet in the {{ category.title }} category ! &lt;/p&gt;
      {% endif %}
  
  {% endblock %}
  </code></pre>
  
  <p><em>post.html</em></p>
  
  <pre><code>{% block content %}
      &lt;h1&gt;{{ post.title }}&lt;/h1&gt;
      &lt;p&gt;{{ post.content }}&lt;/p&gt;
      &lt;small&gt;{{ post.posted }}&lt;/small&gt;
  
  {% endblock %}
  </code></pre>
  
  <p>The error is raised whenever I try to access a specific Post through the links on the <code>category.html</code>. At first, I thought it was because of the regex in the <code>urls.py</code> , but it seems to be a problem with the queries and I have been stuck on it for hours. Any help would be great.</p>
  
  <p><strong>UPDATE</strong> </p>
  
  <pre><code>Traceback:
  
  File "C:\Python27\lib\site-packages\django\core\handlers\exception.py" in inner
    39.             response = get_response(request)
  
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
  _get_response
    187.                 response = self.process_exception_by_middleware(e, request)
  
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
  _get_response
    185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
  File "C:\Users\godfather\PycharmProjects\portfolio\blog\views.py" in post_view
    25.         'post': get_object_or_404(Post, category=slug, slug=slug1)
  
  File "C:\Python27\lib\site-packages\django\shortcuts.py" in get_object_or_404
    85.         return queryset.get(*args, **kwargs)
  
  File "C:\Python27\lib\site-packages\django\db\models\query.py" in get
    376.         clone = self.filter(*args, **kwargs)
  
  File "C:\Python27\lib\site-packages\django\db\models\query.py" in filter
    796.         return self._filter_or_exclude(False, *args, **kwargs)
  
  File "C:\Python27\lib\site-packages\django\db\models\query.py" in
  _filter_or_exclude
    814.             clone.query.add_q(Q(*args, **kwargs))
  
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in add_q
    1227.         clause, _ = self._add_q(q_object, self.used_aliases)
  
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in
  _add_q
    1253.                     allow_joins=allow_joins, split_subq=split_subq,
  
  File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in build_filter
    1183.             condition = lookup_class(lhs, value)
  
  File "C:\Python27\lib\site-packages\django\db\models\lookups.py" in
  __init__
    19.         self.rhs = self.get_prep_lookup()
  
  File "C:\Python27\lib\site-packages\django\db\models\fields\related_lookups.py" in get_prep_lookup
    100.                 self.rhs = target_field.get_prep_value(self.rhs)
  
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py" in get_prep_value
    946.         return int(value)
  
  Exception Type: ValueError at /category/Computer/python-data-scientists/ Exception Value: invalid literal for int() with base 10: 'Computer'
  </code></pre>