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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:17:16+00:00 2026-06-05T16:17:16+00:00

I know the following function can be used to do some pre-save processing. But,

  • 0

I know the following function can be used to do some pre-save processing. But, how can I access the request data, for example a text field value from the request for doing validation?

    def save_model(self, request, obj, form, change):
        # do something for validation 
        obj.save()
  • 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-05T16:17:17+00:00Added an answer on June 5, 2026 at 4:17 pm

    The raw request data is stored in request.POST, as it usually is. It’s probably better to access form.cleaned_data, as Django has already validated it.

    However, the save_model method probably isn’t the correct place to do validation. If you raise a ValidationError, then the exception will not be caught and the user will get a 500 server error page. The save_model method is more appropriate when you know the data is already valid, for example to set the object’s author based on request.user before saving.

    If you want to do custom validation, a better approach would be to define a model form, and use it in your model admin with the ModelAdmin.form setting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know if I can use the following JQuery function on
I get that error with the following code. anyone know why? function validateAdminInput(){ var
I know this is probably a first year question, but I'm having some problems
I'm trying to access some custom data emitted into an SVG document by Visio
I know the Linux command paste can be used to combine two lines in
I have used jquery tabs for loading data with ajax, but I need to
so far, I've successfully used the following function to retrieve the IWebBrowser2 pointer to
Wondering if anyone out there can shed some light on why the following regular
I know following is the way to use unicode in C# string unicodeString =
I would like to know following: I added the folder Graphics into my project

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.