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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:47:03+00:00 2026-05-23T17:47:03+00:00

I have one model, and 3 different forms that use this model (of course,

  • 0

I have one model, and 3 different forms that use this model (of course, each form have different fields of this model). I wrote several clean function to valid the form fill… But, I really dont want copy and past this validation to all forms.

Is it possible to have one common cleaning class? How can I call it?

Here is the actual code:

models.py

class UserProfile(models.Model):      

    user = models.ForeignKey(User, unique=True)

    cpf = models.CharField('CPF', max_length=14, blank=True)
    cnpj = models.CharField('CNPJ', max_length=18, blank=True)

…

forms.py

 class yyyyyForm(UserCreationForm):  
           ...
           def Meta:
              ...
           def Save:
              ...
           def clean_cpf(self):
              ...

class xxxxxForm(UserCreationForm):  
   ...
   def Meta:
      ...
   def Save:
      ...
   def clean_cpf(self):
      ...
  • 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-23T17:47:03+00:00Added an answer on May 23, 2026 at 5:47 pm

    Why don’t you have one baseForm class where you put the clean_cpf() method and then extend that for the other forms, and since clean_cpf is in the parent form, you shouldn’t have to implement it in the child classes.

    In your example it looks like you have a base class called UserCreationForm if that is your form that you can edit then you can put your clean method there.

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

Sidebar

Related Questions

I have a model that contains one-to-one fields to other models. I over rid
I have one grails application.In that I have one model class named Book. From
I have some constants that represent the valid options in one of my model's
I have two forms on one page: a results form and a search form.
I realize this question has been asked several times in several different forms ,
in one of my admin forms, I override a model form field ( location
I have a user control on a form that can spawn several non-modal child
Trying to print out several different forms on the webpage with the data that
I have a view which queries a model to populate a form: class AddServerForm(forms.Form):
I got a simple problem in SQLAlchemy. I have one model in a table,

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.