title: Django trying to split and urlify tags in models, but code isn't working
body: <p>I've got a setup where users can tag their posts, and then other uses can click on those tags to find more posts similar to those. I'm setting it up so that they can use more than one tag per post, split by commas. I can split the tags just fine in models.py, but I want to make them url safe as well and that doesn't seem to be happening. </p>
  
  <p>Instead, it will show me the split words, but not with safe URLs. </p>
  
  <p>This is my models.py:</p>
  
  <pre><code>def urlify(s):
  
       # Remove all non-word characters (everything except numbers and letters)
       s = re.sub(r"[^\w\s]", '', s)    
       # Replace all runs of whitespace with a single dash
       s = re.sub(r"\s+", '-', s)    
       return s
  
  class Post(models.Model):
      created_by = models.ForeignKey(User, related_name='post_created_by')
      pubdate = models.DateTimeField(default=timezone.now)
      title = models.CharField(max_length=200, null=True, blank=True)
      body = models.TextField(null=True, blank=True)
      category = models.CharField(max_length=200, null=True, blank=True)
      tags = models.CharField(max_length=200, null=True, blank=True)
      last_updated = models.DateTimeField(default=timezone.now)
      likes = models.ManyToManyField(User, related_name='post_likes')
  
      def __unicode__(self):
          return self.title
  
      def split_tags(self):
          alltags =  self.tags.split(', ')
          for tag in range(len(alltags)):
              urlify(alltags[tag])
          return alltags
  </code></pre>
  
  <p>in the template I'm returning this:</p>
  
  <pre><code>Tagged: 
                          {% for tag in post.split_tags %}
                              {% if forloop.last %}
                                  &lt;a href="/lobby/posts/tag/{{tag|lower}}/"&gt;{{tag}}&lt;/a&gt;
                              {% else %}
                                  &lt;a href="/lobby/posts/tag/{{tag|lower}}/"&gt;{{tag}}&lt;/a&gt;, 
                              {% endif %}
                          {% endfor %}
  </code></pre>
  
  <p>Would it be better to run the urlify in the views instead of the models? It would be nice if I could display the tags as the user wrote them but keep them URL safe in the background.</p>