Skip to content

Instantly share code, notes, and snippets.

@rixx rixx/
Created Aug 2, 2017

What would you like to do?
Django Url Considerations
from django.db import models
from urlman import NamedUrls
class Event(models.Model):
code = models.CharField(max_length=20)
class urls(NamedUrls):
base = 'orga:event.list'
detail = 'orga:event.view', {'event': self.code}
class Question(models.Model):
event = models.ForeignKey(to=Event, on_delete=models.CASCADE)
class urls(NamedUrls):
base = 'orga:event.questions.list', {'event': self.event.code}
detail = 'orga:event.questions.view', {'event': self.event.code, 'pk':}
from django.conf.urls import include, url
import .views
orga_urls = [
url('^event/$', views.EventList.as_view(), name='event.list'),
url('^event/(?P<event>\w+)/', include([
url('^$', views.EventDashboardView.as_view(), name='event.view'),
url('^questions$', views.QuestionList.as_view(), name='event.questions.list'),
url('^questions/(?P<pk>[0-9]+)$', views.QuestionDetail.as_view(), name='cfp.question.view'),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.