diff options
author | Yaroslav de la Peña Smirnov <contact@yaroslavps.com> | 2018-06-19 04:22:23 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <contact@yaroslavps.com> | 2018-06-19 04:23:25 +0300 |
commit | 2f255efc8f662fa29e8112e6eb9642f33af25ad9 (patch) | |
tree | 4501efac9961a1a54d9a5039c13ce8078859ef38 /weblog | |
parent | 70a234bfafecf2dca8b7c1d0929ae38c76bb2f57 (diff) | |
download | w3blog-2f255efc8f662fa29e8112e6eb9642f33af25ad9.tar.gz w3blog-2f255efc8f662fa29e8112e6eb9642f33af25ad9.zip |
Added on_delete for every foreign key
Diffstat (limited to 'weblog')
-rwxr-xr-x | weblog/models.py | 6 | ||||
-rwxr-xr-x | weblog/templates/weblog/sidebar_archive.html | 8 | ||||
-rwxr-xr-x | weblog/templates/weblog_base.html | 1 | ||||
-rwxr-xr-x | weblog/templates/weblog_base_old.html | 35 |
4 files changed, 39 insertions, 11 deletions
diff --git a/weblog/models.py b/weblog/models.py index 96d9032..3830f6f 100755 --- a/weblog/models.py +++ b/weblog/models.py @@ -7,7 +7,7 @@ from django.utils.translation import ugettext_lazy as _, pgettext_lazy class Category(models.Model): name = models.CharField(max_length=250, verbose_name=pgettext_lazy('Noun, not personal name', 'Name'), blank=False, unique=True) slug = models.SlugField(max_length=60, verbose_name=_('Slug (URL)'), db_index=True, unique=True) - parent_category = models.ForeignKey('self', verbose_name=_('Parent category'), on_delete=models.PROTECT, null=True, blank=True) + parent_category = models.ForeignKey('self', verbose_name=_('Parent category'), null=True, blank=True, default=None, on_delete=models.SET_DEFAULT) def get_absolute_url(self): return reverse('weblog:CategoryIndex', kwargs={'category_slug': self.slug}) @@ -22,7 +22,7 @@ class Category(models.Model): class CategoryTranslation(models.Model): name = models.CharField(max_length=250, verbose_name=pgettext_lazy('Noun, not personal name', 'Name'), blank=False) language = models.CharField(max_length=5, verbose_name=_('Language (ISO)'), blank=False) - category = models.ForeignKey(Category, verbose_name = pgettext_lazy('Post category', 'Category'), on_delete=models.CASCADE, blank=False) + category = models.ForeignKey(Category, verbose_name = pgettext_lazy('Post category', 'Category'), blank=False, on_delete=models.CASCADE) def __str__(self): return self.name @@ -77,7 +77,7 @@ class Translation(models.Model): verbose_name_plural = _('Translations') class PostComment(models.Model): - author = models.ForeignKey(User, verbose_name=_('Author'), on_delete=models.SET_NULL, null=True, blank=True) + author = models.ForeignKey(User, verbose_name=_('Author'), null=True, blank=True, on_delete=models.PROTECT) post = models.ForeignKey(BlogPost, verbose_name=pgettext_lazy('Noun, as in blog post', 'Post'), on_delete=models.CASCADE) content = models.TextField(verbose_name=pgettext_lazy('Of post, comment, article, etc.', 'Content'), blank=False) diff --git a/weblog/templates/weblog/sidebar_archive.html b/weblog/templates/weblog/sidebar_archive.html index ca74018..5953bfe 100755 --- a/weblog/templates/weblog/sidebar_archive.html +++ b/weblog/templates/weblog/sidebar_archive.html @@ -1,6 +1,5 @@ {% load i18n %} <h3>{% trans 'Archive' context 'Blog archive' %}</h3> -{% if archive %} <ul class='archive-list'> {% for a_year in archive %} <li><a class="node-toggle" node-target="{{ a_year.0 }}-list" node-state="closed" href="javascript:void(0)" onclick="toggleNode(this);">+</a> <a href="{% url 'weblog:ArchiveIndex' year=a_year.0 %}">{{ a_year.0 }}</a> @@ -11,9 +10,4 @@ </ul> </li> {% endfor %} -{% else %} -<div class="text-center"> - <p>{% trans 'Nothing has been posted yet.' %}</p> -</div> -{% endif %} -</ul> +</ul>
\ No newline at end of file diff --git a/weblog/templates/weblog_base.html b/weblog/templates/weblog_base.html index ce941e5..9a739cb 100755 --- a/weblog/templates/weblog_base.html +++ b/weblog/templates/weblog_base.html @@ -12,7 +12,6 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<script src="{% static '/weblog/js/weblog.js' %}" defer></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
diff --git a/weblog/templates/weblog_base_old.html b/weblog/templates/weblog_base_old.html new file mode 100755 index 0000000..a4dbd30 --- /dev/null +++ b/weblog/templates/weblog_base_old.html @@ -0,0 +1,35 @@ +<!DOCTYPE html>
+{% load static %}
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Simple blog - {% block title_block %} Home {% endblock %}</title>
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
+ <link rel="stylesheet" href="{% static '/weblog/css/weblog.css' %}">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" defer></script>
+ <script src="{% static '/weblog/js/weblog.js' %}" defer></script>
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" defer></script>
+ </head>
+ <body>
+ <nav class="navbar navbar-inverse">
+ <div class="container nav-container">
+ <div class="navbar-header">
+ <a class="navbar-brand" href="{% url 'weblog:Index' %}">{{ blog_title }}</a>
+ </div>
+ <div class="collapse navbar-collapse">
+ <ul class="nav navbar-nav navbar-right">
+ <li><a href="{% url 'weblog:ChangeLanguage' language='en' %}?next={{ request.path }}">EN</a></li>
+ <li><a href="{% url 'weblog:ChangeLanguage' language='es' %}?next={{ request.path }}">ES</a></li>
+ <li><a href="{% url 'weblog:ChangeLanguage' language='ru' %}?next={{ request.path }}">RU</a></li>
+ </ul>
+ </div>
+ </div>
+ </nav>
+ <div class="container">
+ {% block content_block %}
+ {% block blog_block %}
+ {% endblock %}
+ {% endblock %}
+ </div>
+ </body>
+</html>
\ No newline at end of file |