From 2f255efc8f662fa29e8112e6eb9642f33af25ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Tue, 19 Jun 2018 04:22:23 +0300 Subject: Added on_delete for every foreign key --- README.md | 2 +- setup.py | 2 +- weblog/models.py | 6 ++--- weblog/templates/weblog/sidebar_archive.html | 8 +------ weblog/templates/weblog_base.html | 1 - weblog/templates/weblog_base_old.html | 35 ++++++++++++++++++++++++++++ 6 files changed, 41 insertions(+), 13 deletions(-) create mode 100755 weblog/templates/weblog_base_old.html diff --git a/README.md b/README.md index d38ac9b..b9cd3ed 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Weblog version 0.2 # +# Weblog version 0.3 # Weblog is a simple blog engine for Django, with some focus on multilingual capabilities. It includes all of the basic features expected of a traditional Web log (also known as blog), as well as multilingual features, i.e. translations of blog posts which are delivered automatically in the user's preferred language using the internationalization capabilities of Django, enabling the possibility of targeting people from different countries in a single blog/site. diff --git a/setup.py b/setup.py index 6bb482c..8aa8e04 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='django-weblog', - version='0.3.0', + version='0.3.1', packages=find_packages(), include_package_data=True, license='BSD License', 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 %}

{% trans 'Archive' context 'Blog archive' %}

-{% if archive %} {% endfor %} -{% else %} -
-

{% trans 'Nothing has been posted yet.' %}

-
-{% endif %} - + \ 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 @@ -