Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>"edit: PS - I thought about using the post_init signal... for the code that accesses the db, is that a good idea?"</p> <p>Never.</p> <p>If you have code that's accessing the model before the tables are created, you have big, big problems. You're probably doing something seriously wrong.</p> <p>Normally, you run syncdb approximately once. The database is created. And your web application uses the database.</p> <p>Sometimes, you made a design change, drop and recreate the database. And then your web application uses that database for a long time.</p> <p>You (generally) don't need code in an <code>__init__.py</code> module. You should (almost) never have executable code that does real work in an <code>__init__.py</code> module. It's very, very rare, and inappropriate for Django.</p> <p>I'm not sure why you're messing with <code>__init__.py</code> when <a href="http://code.google.com/p/django-cron/" rel="nofollow noreferrer">Django Cron</a> says that you make your scheduling arrangements in <code>urls.py</code>.</p> <hr> <p><strong>Edit</strong></p> <p>Clearing records is one thing.</p> <p>Messing around with <code>__init__.py</code> and Django-cron's <code>base.py</code> are clearly completely wrong ways to do this. If it's that complicated, you're doing it wrong.</p> <p>It's impossible to tell what you're trying to do, but it should be trivial.</p> <p>Your <code>urls.py</code> can only run after syncdb and after all of the ORM material has been configured and bound correctly.</p> <p>Your <code>urls.py</code> could, for example, delete some rows and then add some rows to a table. At this point, all syncdb issues are out of the way.</p> <p>Why don't you have your logic in <code>urls.py</code>?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload