models.py

slug = models.SlugField(verbose_name='Slug', unique=True)

@models.permalink
def get_absolute_url(self):
    return ('myapp:List', (), {'slug': self.slug})


admin.py
from .models import List01


class ArticleAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}

admin.site.register(List01, ArticleAdmin)

views.py

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

def List(request, slug): 
   list = get_object_or_404(List01, slug=slug, released=True) 
   context = {'list': list} #[1]
   return render(request, 'index.html', context)


urls.py

url(r'^(?P<slug>[\w-]+)/$', 'List', name='index'),

template
{% for lists in list %} # [1]
    <a href="{{lists.get_absolute_url}}"><h2>{{ lists.name }}</h2></a>
{% endfor %)
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8e1f6a05-fffe-403c-a93f-6323269858ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to