Django Slugfield removing articles ('the', 'a', 'an', 'that')
<p>I'm using django 1.10 and I have this setup:</p>

<pre><code>class Chapter(models.Model):
    title = models.CharField(max_length=200, unique=True)
    slug = models.SlugField(unique=True)
    date_completed = models.DateTimeField(blank=True, null=True)

    completed = models.BooleanField(default=False)

    def __str__(self):
        return self.title
</code></pre>

<p>In the admin, I have :</p>

<pre><code>class ChapterAdmin (admin.ModelAdmin):

    list_display = ('title','slug', 'date_completed',)
    list_filter = ['title', 'date_completed']
    prepopulated_fields = {"slug": ("title",)}
</code></pre>

<p>I noticed that when I create a chapter with a title like "A boy and the pig", I get "boy-and-pig" as the slug. Django is stripping of the articles from my slug. Why is this so and what's the way around it?</p>

<p><strong>Why is this so?</strong></p>

<p>Well, that's the default behaviour of the <a href="http://stackoverflow.com/questions/427102/what-is-a-slug-in-django">Slugfield,</a> in Django.  Why is it like that?  Because generally, <a href="http://stackoverflow.com/questions/9734970/better-seo-to-remove-stop-words-from-an-articles-url-slug">it's been considered better for SEO</a>. </p>

<p><em>(I say considered, as the article linked mentions this might be dated thinking. The premise is that  articles and the like are usually considered <a href="https://en.wikipedia.org/wiki/Stop_words" rel="nofollow">Stop Words</a>, the most common words in a language; they're so common that they are unhelpful for a search engine to index, as they feature in most, if not all titles.  )</em></p>

<p><strong>What's the Way Around It?</strong></p>

<p>Firstly - why do you <em>want</em> to get around it?  What's the use case?</p>

<p>But if you're satisified you really want to do it, then it's quite simple:</p>

<pre><code>from django.template.defaultfilters import slugify
would_be_slug = 'This is one of those rarest of things: A blog that uses article.'
slugify(would_be_slug)
&gt;&gt;&gt;u'this-is-one-of-those-rarest-of-things-a-blog-that-uses-article'
</code></pre>

<p><a href="http://stackoverflow.com/questions/3816307/how-to-create-a-unique-slug-in-django">This answer has some great advice</a> on overriding standard fields and slugfields. </p>

<p><a href="https://pypi.python.org/pypi/django-autoslug" rel="nofollow">There's also a nice package</a> that will do this for you if you don't want to roll your own.</p>

python django