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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:38:15+00:00 2026-06-11T06:38:15+00:00

So this is my first project with Django. As a result, I seem to

  • 0

So this is my first project with Django. As a result, I seem to learn new things about how it handles models every day. Because of this, my database is changing every day. Each time I want to update my database, I need to drop it, create it, run syncdb, and then populate it with user data. I was hoping to automate this process with a Python script to save me the hassle of constantly recreating my database.

When I try to run an INSERT command, MySQL is telling me that the column first_name does not have a default value. I took a quick look at the source (https://github.com/django/django/blob/master/django/contrib/auth/models.py), and the class User definitely defines a default value for the first_name column, as well as many others. Does anyone now why I am getting this error?

Here is the relevant part of the script:

import MySQLdb, os
from django.core.management import call_command

os.environ['DJANGO_SETTINGS_MODULE'] = "DatingWebsite.settings"

db = MySQLdb.connect(user = "project", passwd = "project")
c = db.cursor()

try:
    c.execute("DROP DATABASE projectdb;")
except:
    pass
finally:
    c.execute("CREATE DATABASE projectdb;")
call_command('syncdb', interactive=False)
c.execute("USE projectdb;")

c.executemany("""INSERT INTO auth_user (id, username, email, password)
VALUES (%s, %s, %s, %s)""",
[
(1, 'bob', 'bob@gmail.com', 'pbkdf2_sha256$10000$A3ww6NUZ8TmS$5UA2sXCMS6x7uIGKe20hDckmisBY/rGUK7aye/tMUIw='),
] )

Thank you for any help

  • 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-11T06:38:16+00:00Added an answer on June 11, 2026 at 6:38 am

    You may be better of using django south so that you don’t have to recreate your DB every time.

    However, if you want to do recreate the DB, you can try using fixtures to populate data DB.

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

Sidebar

Related Questions

I'm about to start a new django project with friends. This project includes a
This is my first project in django and im using photologue for gallery, which
I'm doing my first project with Django and I'm beginning to think about regrouping
I'm new to Django and for my first project I'm building a portfolio. And
this is my first python project. I am having issues setting up a project
This is my first android project so please help I am trying to create
This is my first azure project and I'm not sure if I'm doing something
This is my first applet project and for some reason when I try to
This was my first Sinatra project - link shortener but I am stuck with
This is my first time doing this sort of project so apologies if the

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.