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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:28:51+00:00 2026-06-03T05:28:51+00:00

I am trying to customize the error message displayed when a user inputs text

  • 0

I am trying to customize the error message displayed when a user inputs text longer than the max length for a CharField in my model. The model defines the field as follows:

name = models.CharField(max_length=200)

I have a ModelForm for this model that defines the form field as follows:

name = forms.CharField(widget=forms.TextInput(attrs={'class':"span8", 'placeholder':'e.g. How do I setup a wi-fi network? How to sync my iPhone with iCloud?'}),
                            error_messages={'required': 'Please enter a question.', 'max_length': 'Your question is too long.'})

This works fine for the ‘required’ error message, but the ‘max_length’ error message still uses Django’s default message here. Am I doing something wrong or should this text be customized in some other way?

  • 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-03T05:28:52+00:00Added an answer on June 3, 2026 at 5:28 am

    The 'max_length' is checked by 'django.core.validators.MaxLengthValidator', which has hard-coded error message. You could replace it w/ your own version by:

    # after the name or ModelForm definition
    name.validators[-1].message = 'Your question is too long.'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the guide http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html i'm trying to customize error message, but i've a problem:
I am using struts2 in my application and trying to diplay error message using
I am trying to customize the error messages shown by Jquery Validate, It is
I'm trying to find a way to customize error messages (404, 403) in my
I'm trying to customize my routes in devise. I've tried to use devise_scope :user,
I'm trying to customize the icons drawn by the GDirections object. I've got a
I am trying to customize a UITableView. So far, it looks good. But when
I am trying to customize Django's comments form. Inside django.contrib.comments.forms I noticed that all
I am trying to customize the output of the comments list and forms using
I'm trying to customize a core WP function using my functions.php file. Why won't

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.