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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:02:18+00:00 2026-05-19T16:02:18+00:00

EDIT: I tried this out again after 3-4 weeks and I did not encounter

  • 0

EDIT: I tried this out again after 3-4 weeks and I did not encounter this problem again. I’m not sure why. I was quite surprised that Django wasn’t throwing up any NOT NULL constraint when I first encountered this problem. But now, when I tried it again after 3-4 weeks, it works fine. I’m not sure why.

Anyway, this question is not really valid any more.

I’m a Django newbie.

My model has a class that has a couple of fields which are defined as NOT NULL.

class Post(models.Model):
    title = models.CharField(max_length=60)
    create_date=models.DateField(verbose_name='created Date')

When I go to the command line (through manage.py shell), and create a new Post instance by doing the following, Django saves the entry to the database:

p=Post(title='test')
p.save()

Why doesn’t it throw up an error like it does when I attempt the same from the Admin panel?

  • 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-19T16:02:18+00:00Added an answer on May 19, 2026 at 4:02 pm

    A few questions

    1. What version of django are you using?
    2. What database are you using?
    3. If you look at your database record after you save via the shell what is in the database for create_date?
    4. If you look at the schema definition for the table in the database does it allow nulls for create_date? Is there a default set?

    I haven’t had a chance to try this code out yet, but this is my guess as to what is going on.

    The django admin is using form validation to stop you from saving, and giving you the error.

    When you use the shell the model doesn’t have validation, so it is allowing you to save, and it is relying on the database to catch the issues with the nullable data. My guess is that your database is allowing this value to be null and isn’t throwing an error and thus it allows you to save with no issues.

    In Django 1.2 they added model validators that are similar to form validators, check out this link for more info.

    http://docs.djangoproject.com/en/1.2/ref/models/instances/#validating-objects

    Once again, I’m just taking a guess here since I don’t know the answers to the questions above. If you could get me those answers I should be able to give you a better answer.

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

Sidebar

Related Questions

EDIT: I wasn't sure if this should be a new question or not so
Controller First I tried this: [HttpPost] public ActionResult Edit(JournalEntry journalentry) { if (ModelState.IsValid) {
Edit: Of course my real code doesn't look exactly like this. I tried to
I tried the following: $.load(Views/chatBox.html).appendTo('body') Console Output: TypeError: $.load is not a function EDIT
Edit: After getting five downvotes but no comments saying anything about why, I've tried
NOTE: THE PROBLEM IS NOT IN THIS CODE, BUT THE ANSWER FOR EXC_BAD_ACCESS is
Ok. I'm stuck once again and it seems that internet just ran out of
Really weird problem. I have a tableView that pulls data out of a Core
Does anyone know how can I edit a subitem on a listView? I've tried
Edit: This question was written in 2008, which was like 3 internet ages ago.

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.