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 9274971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:28:43+00:00 2026-06-18T16:28:43+00:00

Is there a established way that i validate an object in the dispatch without

  • 0

Is there a established way that i validate an object in the dispatch without making an extra database call when self.get_object() is called later in get/post?

Here is what i have so far (slightly altered for this question):

class CourseUpdateView(UpdateView):
    def dispatch(self, request, *args, **kwargs):

        self.request = request
        self.kwargs = kwargs
        self.object = self.get_object()

        if self.object.is_online:
            messages.warning(request, "Sorry this one can't be updated")
            return redirect("course:detail", pk=self.kwargs['pk'])

        # this is going to call self.get_object again isn't it?
        return UpdateView.dispatch(self, request, *args, **kwargs)
  • 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-06-18T16:28:45+00:00Added an answer on June 18, 2026 at 4:28 pm

    You can cache the result of get_object().

    Here’s a trivial example:

    class CourseUpdateView(UpdateView):
        # [...] your dispatch method
    
        def get_object(self):
            # it doesn't matter how many times get_object is called per request
            # it should not do more than one request
            if not hasattr(self, '_object'):
                self._object = super(CourseUpdateView, self).get_object()
            return self._object
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the select menu plugin chosen.js , is there an established way to add
Just curious if there is an established best way to target child elements inside
I'd like to just know if there is a well-established standard way to ensure
So lets say there's a server process that takes way too long. The client
I haven't seen an established way to memoize a function that takes key-word arguments,
Is there a well-established way to share Ant targets between projects? I have a
Is there an established way to parse a string to a Time structure? What
Is there an established pattern for implementing undo/redo functionality in clojure or in fp
.NET's ProviderBase was established in the 2.0 release of the .NET Framework. Have there
Templates are a pretty healthy business in established programming languages, but are there any

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.