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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:03:01+00:00 2026-06-10T05:03:01+00:00

I am using a django DateField in my model. class CalWeek(models.Model): start_monday = models.DateField(verbose_name=Start

  • 0

I am using a django DateField in my model.

class CalWeek(models.Model):
  start_monday = models.DateField(verbose_name="Start monday")

I have a custom validation method that is specific to my modelField: I want to make sure that it is actually a Monday. I currently have no reason to use a custom ModelForm in the admin–the one Django generates is just fine. Creating a custom form class just so i can utilize the clean_start_monday(self)1 sugar that django Form classes provide seems like a lot of work just to add some field validation. I realize I can override the model’s clean method and raise a ValidationError there. However, this is not ideal: these errors get attributed as non-field errors and end up at the top of the page, not next to the problematic user input–not an ideal UX.

Is there an easy way to validate a specific model field and have your error message show up next to the field in the admin, without having to use a custom form class?

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

    You can look into Django Validators.

    https://docs.djangoproject.com/en/dev/ref/validators/

    You would put the validator before the class, then set the validator in the Field.

    def validate_monday(date):
        if date.weekday() != 0:
            raise ValidationError("Please select a Monday.")
    
    class CalWeek(models.Model):
        start_date = models.DateField(validators=[validate_monday])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model in Django: class Bout (models.Model): fighter_1 = models.ForeignKey(Fighter, related_name=bout_fighter_1)
I have django models with a manytomany connection with a through class: class userProfile(models.Model):
using django 1.4 I have a model with a datetimefield. I imported django.utils.timezone to
I have the below db model: from datetime import datetime class TermPayment(models.Model): # I
Using Django with a PostgreSQL (8.x) backend, I have a model where I need
I came across an interesting situation when using this class: class Company(models.Model): date =
I have the following models (I left out def __unicode__(...) for clarity): class Person(models.Model):
I have the following model structure below: class Master(models.Model): name = models.CharField(max_length=50) mounting_height =
I am using django-registration and would like to have a different page for failed
this is how i am doing it right now. class Season(models.Model): Name = models.CharField(max_length=20)

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.