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

  • Home
  • SEARCH
  • 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 901927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:38:16+00:00 2026-05-15T15:38:16+00:00

I have a form for managing users, a ModelForm type. But for two fields

  • 0

I have a form for managing users, a ModelForm type. But for two fields I need a RegexField to validate my data. Because of that I needed to override those fields. But now when I open the form in edit mode (when sending instance of my user) I get no data loaded in both fields. How to avoid it ? Should I forget about regex field and create a custem clean method for them ?

class UserForm(forms.ModelForm):        
    pid = forms.RegexField(regex=r'^\d{11}', max_length=11 ,widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=50)), error_messages=my_default_errors)
    code = forms.RegexField(regex=r'^\d{2}[-]\d{3}', max_length=6, widget=forms.TextInput(attrs=attrs_dict), label="Postal code", error_messages=my_default_errors)

    class Meta:
        model = UserProfile
        exclude = ( 'user', 'image', 'pid' , 'code')

model :

class UserProfile(models.Model):
    def upload_path(self, field_attname):
        filename = hashlib.md5(field_attname).hexdigest()[:4] + "_" + field_attname
        return settings.MEDIA_ROOT + "/uploads/users/%s" % (filename,)
    first_name = models.CharField("Name", max_length=50, blank=True, null=True)
    last_name = models.CharField("Last name", max_length=50, blank=True, null=True)
    pid = models.CharField("PESEL", max_length=11, blank=True, null=True)
    street = models.CharField("Street", max_length=50, blank=True, null=True)
    number = models.CharField("Flat/house number", max_length=10, blank=True, null=True)
    code = models.CharField("Zip ", max_length=6, blank=True, null=True)
    city = models.CharField("City", max_length=50, blank=True, null=True)       
    user = models.ForeignKey(User, unique=True, related_name='profile')
    image = models.ImageField(upload_to=upload_path, verbose_name="Image", blank=True, null=True)
  • 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-15T15:38:17+00:00Added an answer on May 15, 2026 at 3:38 pm

    You set the new field type, which is correct, but then you exclude them from being handled for the model, which is not. Remove them from Meta.exclude.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Each app has a Documents directory where it can write… May 16, 2026 at 12:24 pm
  • Editorial Team
    Editorial Team added an answer The global::myProj.Properties.Settings.Default.sqlconnectionstring; stuff is generated by the settings designer in… May 16, 2026 at 12:24 pm
  • Editorial Team
    Editorial Team added an answer Adobe Acrobat has a very cool but rather well hidden… May 16, 2026 at 12:24 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a database that has lots of data and is all neat, normalized
I have a form which contains 4 text fields when the button is clicked
I have a form submit button that has asp.net validators hooked up to it.
I have a form like this: one.php <form id='myFormId' name='myFormName'> <input type='text' name='myTextField'> <a
i have a form that with a link click adds a new for a
I have a form partial that is being called in a content_for :sidebar. This
I have a form that is validated once the user blurs out of an
I have a form with html browse type and a submit button. I chose
I have been doing more client-side development, managing the UI on the client and
I have an ASP.NET MVC application that uses LINQ2SQL as the database layer. I

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.