<?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>Django foo &#187; Davo</title>
	<atom:link href="http://www.djangofoo.com/author/admin/feed" rel="self" type="application/rss+xml" />
	<link>http://www.djangofoo.com</link>
	<description>Django Tips and Tweaks</description>
	<lastBuildDate>Wed, 18 Aug 2010 09:38:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>DjangoFoo Hosting Updates</title>
		<link>http://www.djangofoo.com/352/djangofoo-hosting-updates</link>
		<comments>http://www.djangofoo.com/352/djangofoo-hosting-updates#comments</comments>
		<pubDate>Wed, 18 Aug 2010 09:38:20 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=352</guid>
		<description><![CDATA[Just a quick entry to let you know the following updates are now available on our DjangoFoo hosting platform Upgraded mod_wsgi to 3.3 New 750GB of backup server available, with weekly backups.]]></description>
			<content:encoded><![CDATA[<p>Just a quick entry to let you know the following updates are now available on our<br />
<strong><a href="http://hosting.djangofoo.com" target="_new">DjangoFoo hosting platform</a></strong></p>
<ul>
<li>Upgraded <a href="http://code.google.com/p/modwsgi/" target="_new">mod_wsgi</a> to 3.3</li>
<li>New <strong>750GB</strong> of <strong>backup</strong> server available, with weekly backups.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/352/djangofoo-hosting-updates/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RequestContext direct_to_template, TEMPLATE_CONTEXT_PROCESSORS</title>
		<link>http://www.djangofoo.com/344/requestcontext-direct_to_template-template_context_processors</link>
		<comments>http://www.djangofoo.com/344/requestcontext-direct_to_template-template_context_processors#comments</comments>
		<pubDate>Thu, 05 Aug 2010 14:28:12 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[RequestContextdirect_to_template]]></category>
		<category><![CDATA[TEMPLATE_CONTEXT_PROCESSORS]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=344</guid>
		<description><![CDATA[If you are wondering why you can&#8217;t use {{ request }} in your templates while using direct_to_template then you probably forgot to edit your TEMPLATE_CONTEXT_PROCESSORS in settings.py The default TEMPLATE_CONTEXT_PROCESSORS is without the django.core.context_processors.request TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.request", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.contrib.messages.context_processors.messages", ) Hope this works for you.]]></description>
			<content:encoded><![CDATA[<p>If you are wondering why you can&#8217;t use <strong>{{ request }}</strong> in your templates while using<br />
<strong>direct_to_template</strong> then you probably forgot to edit your <strong>TEMPLATE_CONTEXT_PROCESSORS</strong> in <strong>settings.py</strong> </p>
<p>The default TEMPLATE_CONTEXT_PROCESSORS is without the <strong>django.core.context_processors.request</strong></p>
<pre class="brush:python">
TEMPLATE_CONTEXT_PROCESSORS = (
      "django.contrib.auth.context_processors.auth",
      "django.core.context_processors.request",
      "django.core.context_processors.debug",
      "django.core.context_processors.i18n",
      "django.core.context_processors.media",
      "django.contrib.messages.context_processors.messages",
)
</pre>
<p>Hope this works for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/344/requestcontext-direct_to_template-template_context_processors/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get SESSION id/key (session_key)</title>
		<link>http://www.djangofoo.com/326/get-session-idkey-session_key</link>
		<comments>http://www.djangofoo.com/326/get-session-idkey-session_key#comments</comments>
		<pubDate>Wed, 23 Jun 2010 09:50:44 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[sessionkey]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=326</guid>
		<description><![CDATA[You can easily grab the session key/id from the request object print request.session.session_key]]></description>
			<content:encoded><![CDATA[<p>You can easily grab the <strong>session key/id</strong> from the request object</p>
<pre class="brush:python">
     print request.session.session_key
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/326/get-session-idkey-session_key/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Autoreload/Restart modwsgi on source change</title>
		<link>http://www.djangofoo.com/320/autoreloadrestart-modwsgi-on-source-change</link>
		<comments>http://www.djangofoo.com/320/autoreloadrestart-modwsgi-on-source-change#comments</comments>
		<pubDate>Sun, 20 Jun 2010 10:50:40 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[autoreloadmodwsgi]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=320</guid>
		<description><![CDATA[When developing with Django&#8217;s DEV server it has a very nice feature, the auto-reload. That is, every time you make changes to a file, the server is automatically restarted. We can have the same with Apache/modwsgi, all you need to do is the following: pre requirements: Linux, python, apache, modwsgi running with WSGIDaemonProcess 1) Find [...]]]></description>
			<content:encoded><![CDATA[<p>When developing with  Django&#8217;s DEV server it has a very nice feature, the auto-reload.<br />
That is, every time you make changes to a file, the server is automatically restarted.  </p>
<p>We can have the same with Apache/modwsgi, all you need to do is the following:<br />
<strong>pre requirements</strong>: Linux, python, apache, modwsgi running with WSGIDaemonProcess</p>
<p>1) Find the <strong>site-packages</strong> of your current python </p>
<pre class="brush:python">
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
</pre>
<p>2) <strong>monitor.py</strong> , copy this file inside your site-packages directory</p>
<pre class="brush:python">
import os
import sys
import time
import signal
import threading
import atexit
import Queue

_interval = 1.0
_times = {}
_files = []

_running = False
_queue = Queue.Queue()
_lock = threading.Lock()

def _restart(path):
    _queue.put(True)
    prefix = 'monitor (pid=%d):' % os.getpid()
    print >> sys.stderr, '%s Change detected to \'%s\'.' % (prefix, path)
    print >> sys.stderr, '%s Triggering process restart.' % prefix
    os.kill(os.getpid(), signal.SIGINT)

def _modified(path):
    try:
        # If path doesn't denote a file and were previously
        # tracking it, then it has been removed or the file type
        # has changed so force a restart. If not previously
        # tracking the file then we can ignore it as probably
        # pseudo reference such as when file extracted from a
        # collection of modules contained in a zip file.

        if not os.path.isfile(path):
            return path in _times

        # Check for when file last modified.

        mtime = os.stat(path).st_mtime
        if path not in _times:
            _times[path] = mtime

        # Force restart when modification time has changed, even
        # if time now older, as that could indicate older file
        # has been restored.

        if mtime != _times[path]:
            return True
    except:
        # If any exception occured, likely that file has been
        # been removed just before stat(), so force a restart.

        return True

    return False

def _monitor():
    while 1:
        # Check modification times on all files in sys.modules.

        for module in sys.modules.values():
            if not hasattr(module, '__file__'):
                continue
            path = getattr(module, '__file__')
            if not path:
                continue
            if os.path.splitext(path)[1] in ['.pyc', '.pyo', '.pyd']:
                path = path[:-1]
            if _modified(path):
                return _restart(path)

        # Check modification times on files which have
        # specifically been registered for monitoring.

        for path in _files:
            if _modified(path):
                return _restart(path)

        # Go to sleep for specified interval.

        try:
            return _queue.get(timeout=_interval)
        except:
            pass

_thread = threading.Thread(target=_monitor)
_thread.setDaemon(True)

def _exiting():
    try:
        _queue.put(True)
    except:
        pass
    _thread.join()

atexit.register(_exiting)

def track(path):
    if not path in _files:
        _files.append(path)

def start(interval=1.0):
    global _interval
    if interval < _interval:
        _interval = interval

    global _running
    _lock.acquire()
    if not _running:
        prefix = 'monitor (pid=%d):' % os.getpid()
        print >> sys.stderr, '%s Starting change monitor.' % prefix
        _running = True
        _thread.start()
    _lock.release()
</pre>
<p>3) Finally edit your application WSGI file and add the following <strong>before your application=django.core.handlers.wsgi.WSGIHandler()</strong>:</p>
<pre class="brush:python">
...
import monitor

monitor.start(interval=5.0) # check every 5 seconds

for root,dirs,files in os.walk('/some/folder/where/your/app/is'):
        for x in files:
            if os.path.splitext(x)[1].lower() == '.py': # only .py files please.
                monitor.track(root + x)
...
</pre>
<p>original code is at <a href="http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Monitoring_For_Code_Changes" target="_new">http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Monitoring_For_Code_Changes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/320/autoreloadrestart-modwsgi-on-source-change/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Django Foo hosting now in Russian</title>
		<link>http://www.djangofoo.com/317/django-foo-hosting-now-in-russian</link>
		<comments>http://www.djangofoo.com/317/django-foo-hosting-now-in-russian#comments</comments>
		<pubDate>Sat, 19 Jun 2010 11:03:56 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[djangorussianhosting]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=317</guid>
		<description><![CDATA[We are pleased to anounce that our hosting platform is now available in Russian. Many thanks to Viktor &#8220;Barbuza&#8221; Kotseruba who helped with the translation.]]></description>
			<content:encoded><![CDATA[<p>We are pleased to anounce that our hosting platform is now available in Russian.<br />
Many thanks to <a href="http://twitter.com/barbuza" target="_new">Viktor &#8220;Barbuza&#8221; Kotseruba</a> who helped with the translation.</p>
<p align="center">
<a target="_new" title="Django Hosting" href="http://hosting.djangofoo.com"><img alt="Django Hosting" src="http://www.djangofoo.com/wp-content/themes/clean-home/images/django_hosting.png"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/317/django-foo-hosting-now-in-russian/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Display Django Version</title>
		<link>http://www.djangofoo.com/313/display-django-version</link>
		<comments>http://www.djangofoo.com/313/display-django-version#comments</comments>
		<pubDate>Fri, 18 Jun 2010 13:36:48 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[getdjangoversion]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=313</guid>
		<description><![CDATA[Ever wondered how to detect which version of Django you are actually running? Well it is as simple as this: >>> import django >>> django.VERSION (1, 2, 1, 'final', 0) >>> django.get_version() u'1.2.1 SVN-13348' >>>]]></description>
			<content:encoded><![CDATA[<p>Ever wondered how to detect which version of Django you are actually running?<br />
Well it is as simple as this:</p>
<pre class="brush:python">
>>> import django
>>> django.VERSION
(1, 2, 1, 'final', 0)
>>> django.get_version()
u'1.2.1 SVN-13348'
>>>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/313/display-django-version/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use javascript, css in admin</title>
		<link>http://www.djangofoo.com/304/use-javascript-css-in-admin</link>
		<comments>http://www.djangofoo.com/304/use-javascript-css-in-admin#comments</comments>
		<pubDate>Wed, 02 Jun 2010 14:17:44 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[admincss]]></category>
		<category><![CDATA[adminjavascript]]></category>
		<category><![CDATA[adminjs]]></category>
		<category><![CDATA[adminmediajs]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=304</guid>
		<description><![CDATA[Ever wanted to use your own JavaScript OR CSS inside the built in Django admin? Well&#8230; it is possible! All you need to do is the following: 1) Add a admin.py (if you don&#8217;t already have yet&#8230;) for your app from django.db import models from django.contrib import admin from myapp.hotels.models import Hotel class HotelAdmin(admin.ModelAdmin): ... [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to use your own <strong>JavaScript</strong> OR <strong>CSS</strong> inside the built in Django <strong>admin</strong>?<br />
Well&#8230; it is possible!</p>
<p>All you need to do is the following:<strong><br />
1)</strong> Add a <strong>admin.py</strong> (if you don&#8217;t already have yet&#8230;) for your app</p>
<pre class="brush:python">
from django.db import models
from django.contrib import admin

from myapp.hotels.models import Hotel

class HotelAdmin(admin.ModelAdmin):
    ...
    class Media:
        js = ("/media/javascript/yourjs.js",)

admin.site.register(Hotel, HotelAdmin)
</pre>
<p><strong>2)</strong> Create a file <strong>yourjs.js</strong> under <strong>/media/javascript</strong></p>
<pre class="brush:python">
(function($) {
    $(document).ready(function($) {
         // you can now use jquery / javascript here...
         alert('It worked.');
    });
})(django.jQuery);
</pre>
<p><strong>3)</strong> Open the admin for your application and you should see the &#8216;It worked&#8217; message.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/304/use-javascript-css-in-admin/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Increment/Decrement Field value</title>
		<link>http://www.djangofoo.com/298/incrementdecrement-field-value</link>
		<comments>http://www.djangofoo.com/298/incrementdecrement-field-value#comments</comments>
		<pubDate>Wed, 26 May 2010 11:43:50 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[incrementdecrement]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=298</guid>
		<description><![CDATA[Incrementing or decrementing field values can be done by using the F() function. UPDATE FIELD = FIELD + 1 WHERE&#8230; ? from django.db.models import F # views.py ... offer = Offer.objects.get(...) # SQL: UPDATE field_to_increment = field_to_increment + 1 ... offer.field_to_increment = F('field_to_increment') + 1 offer.save()]]></description>
			<content:encoded><![CDATA[<p><strong>Incrementing</strong> or <strong>decrementing</strong> field values can be done by using the F() function.<br />
UPDATE FIELD = FIELD + 1 WHERE&#8230; ?  </p>
<pre class="brush:python">
from django.db.models import F

# views.py ...
offer = Offer.objects.get(...)
# SQL: UPDATE field_to_increment = field_to_increment + 1 ...
offer.field_to_increment = F('field_to_increment') + 1
offer.save()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/298/incrementdecrement-field-value/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django hosting</title>
		<link>http://www.djangofoo.com/286/django-hosting</link>
		<comments>http://www.djangofoo.com/286/django-hosting#comments</comments>
		<pubDate>Fri, 14 May 2010 16:14:50 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=286</guid>
		<description><![CDATA[After a month of hard work we are proud to announce that our new django hosting service is up and running! The main features include : Live logs manage.py Money back guanrantee Django version switcher Your own domain name 500Mb file storage 100Mb database storage Import code from SVN or GIT Django Foo hosting]]></description>
			<content:encoded><![CDATA[<p>After a month of hard work we are proud to announce that our new <strong>django hosting</strong> service is up and running!<br />
<br />
<a href="http://hosting.djangofoo.com"><img src="http://hosting.djangofoo.com/media/images/general/screenshot.jpg" alt="Django Hosting" /></a><br />
<strong>The main features include :</strong></p>
<ul>
<li>Live logs</li>
<li>manage.py</li>
<li>Money back guanrantee</li>
<li>Django version switcher</li>
<li>Your own domain name</li>
<li>500Mb file storage</li>
<li>100Mb database storage</li>
<li>Import code from SVN or GIT</li>
</ul>
<p><strong><a href="http://hosting.djangofoo.com">Django Foo hosting</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/286/django-hosting/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django paypal sandbox</title>
		<link>http://www.djangofoo.com/282/django-paypal-sandbox</link>
		<comments>http://www.djangofoo.com/282/django-paypal-sandbox#comments</comments>
		<pubDate>Fri, 14 May 2010 08:21:35 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[djangopaypalsandbox]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=282</guid>
		<description><![CDATA[When using the django-paypal pluggable app there is not really a settings to specify if you want to interact with the sandbox or with the normal site. To do this you need to call the the form like this {{ form.sandbox }} instead of {{ form.render }}]]></description>
			<content:encoded><![CDATA[<p>When using the <a href="http://github.com/johnboxall/django-paypal" target="_new">django-paypal</a> pluggable app there is not really a settings to specify if you want to interact with the <strong>sandbox</strong> or with the normal site.<br />
To do this you need to call the the form like this</p>
<pre class="brush:python">
{{ form.sandbox }}
</pre>
<p>instead of </p>
<pre class="brush:python">
{{ form.render }}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/282/django-paypal-sandbox/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

