Django - problems with URLS mapping and dispatcher
<p>I'm learning Django and I would like to build an application with the calendar and tasks, where every task has a separate link via <code>get_absolute_url</code>. I've created a list of activities and url link to each of them, but when I pick one of them there is no reaction, not even an error message. </p>

<p>Please find my code below.</p>

<pre><code>from django.db import models
from django.utils import timezone
from django.core.urlresolvers import reverse

class PublishedManager(models.Manager):
    def get_queryset(self):
        return super(PublishedManager,self).get_queryset().order_by('hour')

class Activity(models.Model):
    STATUS_CHOICES = (
        ('30 min', '30 min'),
        ('1:00 h', '1:00 h'),
        ('1:30 h', '1:30 h'),
        ('2:00 h', '2:00 h'),
        ('2:30 h', '2:30 h'),
        ('3:00 h', '3:00 h'),
        ('3:30 h', '3:30 h'),
        ('4:00 h', '4:00 h'),
        ('4:30 h', '4:30 h'),
        ('5:00 h', '5:00 h'),
    )
    title = models.CharField(max_length=250)
    slug = models.SlugField(max_length=250, unique_for_date='hour')
    body = models.TextField()
    hour = models.DateTimeField(default=timezone.now())
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)
    objects = models.Manager()
    duration = models.CharField(max_length=10, choices=STATUS_CHOICES, default='30 min')
    published = PublishedManager()

    class Meta:
        ordering = ('-hour',)

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('core_tm:activity_detail',
                       args=[self.slug])


from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^', views.activity_list, name='activity_list'),
    url(r'^(?P&lt;activity&gt;[-\w]+)/$',
        views.activity_detail, name='activity_detail')


from django.shortcuts import render, get_object_or_404
from .models import Activity

def activity_list(request):
    activities = Activity.published.all()
    return render(request, 'core_tm/activity/list.html', {'activities' : activities})

def activity_detail(request, activity):
    activity = get_object_or_404(Activity, slug=activity)
    return render(request, 'core_tm/activity/detail.html', {'activity' : activity})
</code></pre>

<p>List template:</p>

<pre><code>{% extends "core_tm/base.html" %}

{% block title %}&lt;h1&gt;Lista aktywnoÅci&lt;/h1&gt;{% endblock %}

{% block content %}
    {% for activnes in activities %}
        &lt;h2&gt;
            &lt;a href="{{ activnes.get_absolute_url }}"&gt;
                {{ activnes.title }}
            &lt;/a&gt;
        &lt;/h2&gt;
        &lt;p class="date"&gt;
            Data rozpoczÄcia : {{ activnes.hour }}
            Czas trwania : {{ activnes.duration }}
        &lt;/p&gt;
        {{ activnes.body|truncatewords:30|linebreaks }}
    {% endfor %}

{% endblock %}
</code></pre>

<p>Detail template:</p>

<pre><code>{% extends "core_tm/base.html" %}

{% block title %}{{ activity.title }}{% endblock %}

{%block content %}
    &lt;h1&gt;{{ activity.title }}&lt;/h1&gt;
    &lt;p class="date"&gt;
        Data rozpoczÄcia : {{ activity.hour }}
        Czas trwania : {{ activity.duration }}
    &lt;/p&gt;
    {{ activity.body|linebreaks }}

{% endblock %}
</code></pre>

<p>You need to terminate your activity_list URL:</p>

<pre><code>url(r'^$', views.activity_list, name='activity_list'),
</code></pre>

<p>Otherwise this will simply match all paths, including those that are supposed to point to your activities.</p>

python django url