<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rlazo&#039;s blog &#187; Django</title>
	<atom:link href="http://www.rlazo.org/category/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rlazo.org</link>
	<description></description>
	<lastBuildDate>Sat, 08 May 2010 18:24:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Elisp func to create a dummy admin.py</title>
		<link>http://www.rlazo.org/2009/03/10/elisp-func-to-create-a-dummy-admin-py/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.rlazo.org/2009/03/10/elisp-func-to-create-a-dummy-admin-py/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 15:57:30 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Emacs]]></category>

		<guid isPermaLink="false">http://www.rlazo.org/?p=68</guid>
		<description><![CDATA[While writing a django app, I faced the tedious task of updating the corresponding admin.py file for the models I was writing. Because I didn&#8217;t want to customize any of the admin options just yet all I had to do is insert new register entries on the file (one for model). I grew tired of [...]]]></description>
			<content:encoded><![CDATA[<p>While writing a django app, I faced the tedious task of updating the corresponding admin.py file for the models I was writing. Because I didn&#8217;t want to customize any of the admin options just yet all I had to do is insert new register entries on the file (one for model). I grew tired of this pretty soon so I wrote this elisp function to update an admin.py file easily. Hope this helps somebody
</p>
<div class="codehilite">
<pre><span class="p">(</span><span class="nb">defun</span> <span class="nv">rl/django-admin-all-models</span><span class="p">()</span>
<span class="p">(</span><span class="nv">interactive</span><span class="p">)</span>
<span class="p">(</span><span class="k">let</span> <span class="p">((</span><span class="nv">content</span> <span class="s">&quot; &quot;</span><span class="p">))</span>
  <span class="p">(</span><span class="nv">with-temp-buffer</span>
    <span class="p">(</span><span class="nv">insert</span> <span class="s">&quot;from models import *\n&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">insert</span> <span class="s">&quot;from django.contrib import admin\n\n&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="k">let</span> <span class="p">((</span><span class="nv">text-start</span> <span class="p">(</span><span class="nv">point</span><span class="p">)))</span>
  <span class="p">(</span><span class="nv">insert-file-contents</span> <span class="s">&quot;models.py&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nv">keep-lines</span> <span class="s">&quot;^class.*$&quot;</span> <span class="nv">text-start</span> <span class="p">(</span><span class="nv">point-max</span><span class="p">))</span>
  <span class="p">(</span><span class="nv">while</span> <span class="p">(</span><span class="nv">re-search-forward</span> <span class="s">&quot;^class \\(\\w+\\).*&quot;</span> <span class="no">nil</span> <span class="no">t</span><span class="p">)</span>
    <span class="p">(</span><span class="nv">replace-match</span> <span class="s">&quot;admin.site.register(\\1)&quot;</span><span class="p">))</span>
  <span class="p">(</span><span class="nv">write-file</span> <span class="s">&quot;admin.py&quot;</span> <span class="no">nil</span><span class="p">)))))</span>
</pre>
</div>
<p>A word of warning: this <strong>will</strong> override your current admin.py</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rlazo.org/2009/03/10/elisp-func-to-create-a-dummy-admin-py/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Documenting a Django project with Sphinx</title>
		<link>http://www.rlazo.org/2008/10/24/documenting-a-django-project-with-sphinx/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.rlazo.org/2008/10/24/documenting-a-django-project-with-sphinx/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 16:12:40 +0000</pubDate>
		<dc:creator>Rodrigo</dc:creator>
				<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://www.rlazo.org/?p=47</guid>
		<description><![CDATA[Sphinx is a documentation tool written for python (but could be used
on other circumstances). I&#8217;ve learning how to used and I wanted to
document a django project I&#8217;ve been working on, but when you try to
import your modules you get an exception

 autodoc can't import/find module '&#60;yourmodule&#62;', it reported error:
 "Settings cannot be imported, because environment [...]]]></description>
			<content:encoded><![CDATA[<p>Sphinx is a documentation tool written for python (but could be used<br />
on other circumstances). I&#8217;ve learning how to used and I wanted to<br />
document a django project I&#8217;ve been working on, but when you try to<br />
import your modules you get an exception</p>
<div>
<pre> autodoc can't import/find module '&lt;yourmodule&gt;', it reported error:
 "Settings cannot be imported, because environment variable
 DJANGO_SETTINGS_MODULE is undefined.",please check your spelling
 and sys.path</pre>
</div>
<p>This happens because django do some enviroment settings before using<br />
your app, so I wanted to do the same with. It was easier than I<br />
tought, just put the following snippet in your sphinx conf.py</p>
<div>
<pre class="python">from MYPROJECT import settings
from django.core.management import setup_environ

setup_environ(settings)</pre>
</div>
<p>of course, for it to work you need to modify your path, in my case was:</p>
<div>
<pre class="python">sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/../../'))</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.rlazo.org/2008/10/24/documenting-a-django-project-with-sphinx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
