-1

I use django 1.10.5. I have a problem with open unique url, views:

entry = get_object_or_404(Post, slug=slug)

model field:

slug = models.SlugField(editable=False)

i need to detect slug with identical string, for example i have slug xyz and xYz i need to open other pages, now django display 500 page on production.

url(r'^(?P<slug>[\w-]+)/$', views.single_post, name='single_post'),

And error message:

MultipleObjectsReturned at /pZw/ get() returned more than one Post -- it returned 2!

how i can detect if is identical?

Random User
  • 73
  • 1
  • 9

1 Answers1

0

Well what's happening is you are getting two results where get_object_or_404 is expected to return only 1. Your field slug is not unique and have some inconsistency. Can you try this.

entry = get_object_or_404(Post, slug__exact=slug)
Bipul Jain
  • 4,523
  • 3
  • 23
  • 26