Skip to content

Instantly share code, notes, and snippets.

@mammuth
Created January 3, 2018 16:27
Show Gist options
  • Save mammuth/75c50f03648b1d5a8e4741fc317c4216 to your computer and use it in GitHub Desktop.
Save mammuth/75c50f03648b1d5a8e4741fc317c4216 to your computer and use it in GitHub Desktop.
# models.py
class Job(models.Model):
slug = models.SlugField(max_length=60)
@models.permalink
def get_absolute_url(self):
return 'career:job-detail', (self.pk, self.slug)
# urls.py
path('<int:id>/<slug:slug>/', JobDetailView.as_view(), name='job')
# admin.py
prepopulated_fields = {'slug': ('title',)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment