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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:59:50+00:00 2026-06-03T09:59:50+00:00

My tables are specified as models in Python, which are then made into MySQL

  • 0

My tables are specified as models in Python, which are then made into MySQL tables by Django. In Python:

class my_table(models.Model):
    is_correct = models.IntegerField(default = 0)

If I do an insert into this table then I want it to automatically insert 0 for the column is_correct unless I specify a different value. I also want this to happen if I am using raw sql or if I am inserting from a MySQL stored procedure.

The default argument only seems to work from within Python. It’s not translated into anything that MySQL sees. Is such a thing possible?

  • 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-03T09:59:53+00:00Added an answer on June 3, 2026 at 9:59 am

    Yes, default argument works on django level. If you want to move it to mysql, perform ALTER TABLE ... query manually.

    You also can try to extend models.IntegerField and override db_type. But it should be done for every field…

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

Sidebar

Related Questions

When I tried to add a new table to python/flask - class UserRemap(db.Model): name
I have a django application which has one main table/model which references various 'lookup'
I've got three tables which all join into one table. Here is the code:
I want to find which tables are related to a specific table. I can
I am using South with Django for database migrations. In my models.py I changed
I have a n...n structure for two tables, makes and models . So far
How can I prevent Django, for testing purposes, from automatically fetching related tables not
In Doctrine2.0.6, I keep getting an error: Column VoucherId specified twice. The models in
So I have two rails models - user and role - each specified with
I have the following zendframework model classes class Application_Model_DbTable_Mobile extends Zend_Db_Table_Abstract { protected $_name

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.