Commit 90932fdb authored by Daniel W Bond's avatar Daniel W Bond
Browse files

modified major object slug field

parent c280cedf
This diff is collapsed.
...@@ -23,12 +23,11 @@ class Major(TimeStampedModel): ...@@ -23,12 +23,11 @@ class Major(TimeStampedModel):
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
# I believe the longest is "Government and International Politics" # I believe the longest is "Government and International Politics"
slug = AutoSlugField(populate_from='name', unique=True) slug = AutoSlugField(populate_from='name', always_update=True, unique=True)
# always_update is set to support migrating from previous versions' slugs
# don't fix this just yet-- coincide with end of semester when everyone's # which were originally random characters
# changing up their accounts anyway # on always_update, the slug is modified whenever the populated_from field changes
#name_slug = AutoSlugField(populate_from='name') # custom function to delete # to update from previous versions, call .save() on all existing models
# ba/bs/etc
def first_letter(self): def first_letter(self):
return self.name and self.name[0] or '' return self.name and self.name[0] or ''
...@@ -40,10 +39,7 @@ class Major(TimeStampedModel): ...@@ -40,10 +39,7 @@ class Major(TimeStampedModel):
return unicode(self.name) return unicode(self.name)
def get_absolute_url(self): def get_absolute_url(self):
return reverse('detail_major', kwargs={ return reverse('detail_major', kwargs={'slug': self.slug})
'slug': self.slug,
'major': slugify(self.name),
})
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
......
...@@ -17,7 +17,7 @@ urlpatterns = patterns('', ...@@ -17,7 +17,7 @@ urlpatterns = patterns('',
# majors pages # majors pages
url(r'^majors/$', ListMajors.as_view(), name='list_majors'), url(r'^majors/$', ListMajors.as_view(), name='list_majors'),
url(r'^majors/(?P<slug>[\w-]+)/(?P<major>[\w-]+)/$', url(r'^majors/(?P<slug>[\w-]+)/$',
DetailMajor.as_view(), name='detail_major'), DetailMajor.as_view(), name='detail_major'),
# student profile pages # student profile pages
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment