Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:22:38+00:00 2026-05-25T01:22:38+00:00

I am currently making views called by slug s on django but I seem

  • 0

I am currently making views called by slugs on django but I seem to have some troubles on that.

Suppose I have database entries like de ce ceiling (slug fields).
Now when I call, myapp/ce or myapp/de. It returns the view I want. But when I call myapp/ceiling, it returns 404.

No sculpture found matching the query

It catches the url though.

The problem occurs when I use capital letter on the name field. The other fields hold lowercase.

I failed to understand this behavior.

My code is as follows:

urls.py

urlpatterns = patterns('sculptures.views',
            (r'^$', SculptureListView.as_view()),
            (r'^(?P<slug>[\w-]+)/$', SculptureDetailView.as_view()),
        )

views.py

class SculptureDetailView(DetailView):
    context_object_name = 'sculpture'
    def get_queryset(self):
        sculpture_slug = get_object_or_404(Sculpture, slug__iexact=self.kwargs['slug'])
        return Sculpture.objects.filter(slug=sculpture_slug)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:22:38+00:00Added an answer on May 25, 2026 at 1:22 am

    Looking at your code:

    def get_queryset(self):
        sculpture_slug = get_object_or_404(Sculpture, slug__iexact=self.kwargs['slug'])
    

    Here you’re fetching the Sculpture object that matches the captured slug.

        return Sculpture.objects.filter(slug=sculpture_slug)
    

    And then you get the Sculpture object whose slug is another Sculpture object. I wonder how this even works in some cases 🙂

    Since you have a DetailView, you can directly use get_object():

    class SculptureDetailView(DetailView):
        def get_object(self):
            return get_object_or_404(Sculpture, slug__iexact=self.kwargs['slug'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently making some system that will gather statistical reports from different sites, for
I'm having some trouble with an iPhone app that I'm making. I have two
I currently have a partial view that is called within my _Layout.cshtml, and is
I'm currently making a C++ game. I have my main loop during which the
I'm currently making a GWT project where I display some HTML in a RichTextArea
I'm currently making an iPhone app that has PDF viewing a crucial part of
I'm currently making a PHP-program that solves equations. I've divided the input equation into
I have some problems with OnTouchListener . I want that everytime when user touch
I'm making a database of an imaginary Airport that has a simplified physical model
I'm currently making ipad application. I have create an uiviewcontroller which is appear with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.