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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:51:05+00:00 2026-06-15T04:51:05+00:00

I have some existing SQL statements that I’d like to use as a custom

  • 0

I have some existing SQL statements that I’d like to use as a custom hook after the CREATE TABLE command, in [myapp]/sql/[model-name].sql.

My app is in INSTALLED_APPS. I see listed if I run ./manage.py sql.

My custom hook is found; I see the SQL statements output if I run any of the following:

./manage.py sqlall <myapp>
./manage.py sqlcustom <myapp>
./manage.py sql <myapp>

I’m using postgres 9.x on my mac.

If I psql to that same database (with no user) and copy them from the .sql file and paste them into the psql command input, they all work… so I believe they’re valid SQL understood by postgres. These are all pretty simple INSERT statements (fixtures addressed below).

However, if I run ./manage.py syncdb those statements are either not run, or they are ignored or silent errors happen; all I know is that the new rows do not appear in the database. I am tailing the postgres log file and nothing is logged when I run syncdb, so I don’t know if it’s not finding my .sql file, or parsing it and finding some error before it gets to the database.

I have created a .json file, for fixtures, with the equivalent of those statements, and ./manage.py loaddata <path-to-json-file> works correctly: my site now shows those values in the database. This makes me believe that my settings file is correct and the database I’m writing to inside postgres is set correctly, and I have write permissions when I run ./manage.py.

I saw in some other post that the django documentation is wrong and I should put the custom hook in the ‘models’ directory, but I don’t know if that’s right; if sqlall and sqlcustom find my hook, shouldn’t syncdb find it? Also I don’t (yet) have a models directory and may not need it.

For various reasons I’d rather not use JSON format, but if I have to I will… however I’ve invested so much time in the .sql format I really want to know what’s going on (and I’ve seen enough existing related questions that this might help others).

  • 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-15T04:51:06+00:00Added an answer on June 15, 2026 at 4:51 am

    I believe I found it, although it’s based on behaviors not any real research. I simply changed ’tile’ to ’tilexx’ everywhere and it worked. This django-project post indicates that if there is some sort of python class name conflict the custom SQL won’t be executed… and ’tile’ is a pretty common thing.

    So the answer is to change the name of my class to something a bit more unique.

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

Sidebar

Related Questions

I have two already-existing tables which look (in part) roughly like this: CREATE TABLE
I have an existing SQL 2005 stored procedure that for some reason, outputs its
I have some existing WCF code that accesses SQL Server 2005, but honestly I've
I have some existing custom Excel workbooks/applications with code-behind C#, which work fine. They
I have some existing code that worked fine under Windows 2003, to obtain the
After searching through some existing libraries for JSON, I have finally ended up with
I have a table stored on a SQL Server 2008, that associate a value
I have an existing web application that I am converting to use CakePHP. The
I have some records that were imported to SQL. One of the fields 'FieldToChage'
I have some existing code that retrieves data from a database using ADO.NET that

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.