Josh VanderLinden  committed 9a5d164

#14 - Trying to fix the migration for adding the slug column

  • Participants
  • Parent commits 965c76b

Comments (0)

Files changed (5)

File articles/migrations/

     def forwards(self, orm):
         # Adding field 'Tag.slug'
-        db.add_column('articles_tag', 'slug','django.db.models.fields.CharField')(default='', unique=True, max_length=64, null=True, blank=True), keep_default=False)
+        db.add_column('articles_tag', 'slug','django.db.models.fields.CharField')(default='', max_length=64, null=True, blank=True), keep_default=False)
+        # find all tags with an empty slug
+        for tag in orm.Tag.objects.filter(slug=''):
+            # trigger the automatic slug population
+        # now add the unique constraint
+        db.alter_column('articles_tag', 'slug','django.db.models.fields.CharField')(default='', unique=True, max_length=64, null=True, blank=True))
     def backwards(self, orm):

File articles/

+from base64 import encodestring
+from datetime import datetime
+import mimetypes
+import re
+import urllib
 from django.db import models
 from django.db.models import Q
 from django.contrib.auth.models import User
 from django.conf import settings
 from django.template.defaultfilters import slugify, striptags
 from django.utils.translation import ugettext_lazy as _
-from datetime import datetime
-from base64 import encodestring
-import mimetypes
-import re
-import urllib
 WORD_LIMIT = getattr(settings, 'ARTICLES_TEASER_LIMIT', 75)
 AUTO_TAG = getattr(settings, 'ARTICLES_AUTO_TAG', True)

File articles/templatetags/

             # determine what view we are using based upon the path of this page
             view, args, kwargs = resolve(context['request'].path)
         except (Resolver404, KeyError) as err:
-            print err
             raise ValueError('Invalid pagination page.')
             # set the page parameter for this view

File requirements.txt


File sample/articles_demo/demo.db

Binary file modified.