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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:57:07+00:00 2026-05-23T09:57:07+00:00

Ok, so I have a model like this: class Airplane(models.Model): tail = models.ForeignKey(Tails) wheel

  • 0

Ok, so I have a model like this:

class Airplane(models.Model):
    tail = models.ForeignKey(Tails)
    wheel = models.CharField(max_length=500,blank=True)
    window = models.CharField(max_length=500,blank=True)

    def clean(self):
        if self.tail and self.wheel and self.window:
            raise ValidationError("Can't have all three, choose tail and one more")

Now if I go to add a new Airplane record using Django admin. If I leave both fields blank and save I get this Django error pointing to the line if self.tail and self.wheel.

DoesNotExist at /admin/MyProject/airplane/add/

Request Method:     POST
Request URL:    http://44.101.44.172:8001/admin/MyProject/airplane/add/
Django Version:     1.2.5
Exception Type:     DoesNotExist
Exception Value:    

Exception Location:     /usr/lib/python2.7/site-packages/django/db/models/fields/related.py in __get__, line 299
Python Executable:  /usr/bin/python
Python Version:     2.7.0

Shouldn’t Django be checking that the required fields are filled in before running clean? In any case, what’s the best way to handle this issue?

  • 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-23T09:57:07+00:00Added an answer on May 23, 2026 at 9:57 am

    Ok, as a workaround I ended up defining a custom form with my validation in admin.py for this model.

    I still don’t understand why model.clean gets called before Django has determined that the required fields have been filled in. Oh well.

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

Sidebar

Related Questions

I have model like this: class Kaart(models.Model): name = models.CharField(max_length=200, verbose_name=Kaardi peakiri, help_text=Sisesta kaardi
I have a model like this: class Entity(models.Model): entity_name = models.CharField(max_length=100) entity_id = models.CharField(max_length=30,
I have a model like this: class database(models.Model): db_name = models.CharField('Name', max_length=20) server =
My django model looks like this: class Entity(models.Model): name = models.CharField(max_length=40) examples = models.ManyToManyField(Example,
I have a models A and B , that are like this: class A(models.Model):
I have a model like this: class Task(models.model): TASK_STATUS_CHOICES = ( (uP, u'Pending'), (uA,
Let's say I have a model like this class Foo(db.Model): id = db.StringProperty() bar
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
Specifically, I have a model that has a field like this pub_date = models.DateField(date
I have a model like this: class Transaction < ActiveRecord::Base def amount self[:amount].abs end

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.