def clean_slug(self):
        """The slug + the publish_date must be unique together"""

        if 'publish_date' in self.cleaned_data:
            publish_date = self.cleaned_data['publish_date']
            try:
                Story.objects.get(
                    slug=self.cleaned_data['slug'],
                    publish_date__year=publish_date.year,
                    publish_date__month=publish_date.month,
                    publish_date__day=publish_date.day)
                raise forms.ValidationError(
                    'Please enter a different slug. The one you'\
                    'entered is already being used for {0}'.format(
                         publish_date.strftime("%Y-%b-%d")))
            except Story.DoesNotExist:
                pass

        return self.cleaned_data['slug']
dataset/ETHPy150Open callowayproject/django-stories/stories/forms.py/StoryForm.clean_slug/original