EatEmAll / django-djeddit

Minimalistic Reddit clone developed as a Django reusable app
http://eatemall.pythonanywhere.com
Other
42 stars 13 forks source link

Will Djeddit updates break old instances due to slug? #19

Closed Zerokami closed 6 years ago

Zerokami commented 6 years ago
def _genSlug(self):
        slug = slugify(self.title, to_lower=True, max_length=80)
        return slug

@EatEmAll This is the code you updated. You removed threadSlugPage and made it into slugPage and removed if self.slug: checks.

What if there are old posts with no slug? I'm not sure if it's gonna break, but I want to be sure.

EatEmAll commented 6 years ago

I've ensured that existing Thread objects will have slugs by adding them in migrations/0004_thread_slug.py:

from djeddit.models import Thread

def genSlugs(apps, schema_editor): for t in Thread.objects.all().iterator(): t.save()