Josh VanderLinden committed 9a5d164

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

Comments (0)

Files changed (5)


     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):


+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)


             # 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
Add a comment to this file


Binary file modified.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.