djangosnippets.org: Latest snippets posted by alia_khourihttps://djangosnippets.org/users/alia_khouri/2008-09-02T09:31:24.872936-05:00alia_khourieasy admin registration
2008-09-02T09:31:24.872936-05:00alia_khourihttps://djangosnippets.org/snippets/1015/<p>This essentially wraps <a href="http://www.djangosnippets.org/snippets/917/">snippet 917</a> (with full credit to author ncw) in a convenience function so that you can type:</p>
<pre><code>admin_register(admin, namespace=globals())
</code></pre>
<p>or more concisely:</p>
<pre><code>admin_register(admin, globals())
</code></pre>
<p>at the end of your admin.py file without having to register each model and admin class individually.</p>
Freely redistributabledjangopath: conveniently set sys.path and DJANGO_SETTINGS_MODULE
2008-08-07T10:56:49.170471-05:00alia_khourihttps://djangosnippets.org/snippets/948/<p>In the past, whenever I had a script that I wanted to properly configure the settings for, I would use something like the following idiom at the top of the script:</p>
<pre><code>import sys, os; dirname = os.path.dirname
# sys.path.insert(0, dirname(dirname(__file__)))
sys.path.insert(0, dirname(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
</code></pre>
<p>Notice that this is a …</p>
Freely redistributable