-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
74 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
from django.db import models | ||
from django.urls import NoReverseMatch, reverse | ||
|
||
from autoslug import AutoSlugField | ||
|
||
|
||
# Create your models here. | ||
class Blog(models.Model): | ||
title = models.CharField(max_length=100) | ||
content = models.TextField() | ||
slug = AutoSlugField(populate_from="title", editable=True, blank=True) | ||
date_posted = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
def get_absolute_url(self, *args, **kwargs): | ||
try: | ||
return reverse( | ||
"blog:detail", | ||
kwargs={ | ||
"slug": self.slug, | ||
}, | ||
) | ||
except NoReverseMatch: | ||
pass | ||
return "" | ||
|
||
def get_title(self): | ||
return self.title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
from django.conf.urls.i18n import i18n_patterns | ||
from django.contrib import admin | ||
from django.urls import path | ||
from django.urls import include, path, re_path | ||
|
||
urlpatterns = [ | ||
path("admin/", admin.site.urls), | ||
] | ||
urlpatterns += i18n_patterns( | ||
re_path(r"^", include("cms.urls")), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters