Search code examples
djangodjango-syncdb

Is there any way to get syncdb to pull in models that aren't in models.py?


I have a file filled with models embedded deep within my app and not in a models.py file or models directory.

Basically it's a file that points to tables on a legacy database, which is why I put it in a separate file.

However, now that I'm trying to set up a testing version, I need to be able to create all the tables via syncdb.

Is there any way for me to do this? Or must I create the tables manually using SQL?


Solution

  • temp_app/models.py

    from my.deep.in.code.modelfile import model1
    from my.deep.in.code.modelfile import model2
    

    Add temp_app to installed apps (make sure you also have init.py in the dir)

    Run Syncdb

    Remove temp_app from installed apps