<?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"
	>

<channel>
	<title>pyxx.org</title>
	<atom:link href="http://pyxx.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://pyxx.org</link>
	<description></description>
	<pubDate>Mon, 25 Aug 2008 12:44:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.4-bleeding</generator>
	<language>en</language>
			<item>
		<title>How to extend user model in Django and enable new fields in &#8216;newforms-admin&#8217;</title>
		<link>http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-enable-new-fields-in-newforms-admin/</link>
		<comments>http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-enable-new-fields-in-newforms-admin/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 13:21:32 +0000</pubDate>
		<dc:creator>Sasha Philippov</dc:creator>
		
		<category><![CDATA[Django]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-enable-new-fields-in-newforms-admin/</guid>
		<description><![CDATA[The way to specify admin interface options has changed in the recent development version of Django. An inline edited objects are now specified in a new way. Now you need to mention the link in an admin objects of both models participating in the relation.

So the question arises: how to make UserProfile to appear inline [...]]]></description>
			<content:encoded><![CDATA[<p>The way to specify admin interface options has changed in the recent development version of Django. An inline edited objects are now specified in a new way. Now you need to mention the link in an admin objects of both models participating in the relation.</p>

<p>So the question arises: how to make <em>UserProfile</em> to appear inline in the <em>User</em> editing interface in admin?</p>

<p>The solution is to import <em>UserAdmin</em> class and add an <em>InlineAdmin</em> objet to the inlines list. But there is a simple trick: you need to unregister and then register an <em>AdminModel</em> class for a <em>User</em> model. Here is an example.</p>

<p><strong>models.py</strong></p>

<pre><code>from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
    website_url = models.URLField(verify_exists=False)
    user = models.ForeignKey(User, unique=True)
</code></pre>

<p><strong>admin.py</strong></p>

<pre><code>from django.contrib import admin
from someapp.models import *
from django.contrib.auth.admin import UserAdmin

# Define an inline admin descriptor for UserProfile model
class UserProfileInline(admin.TabularInline):
    model = UserProfile
    fk_name = 'user'
    max_num = 1

# Define a new UserAdmin class
class MyUserAdmin(UserAdmin):
    inlines = [UserProfileInline, ]

# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-enable-new-fields-in-newforms-admin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Nokia 5310 XpressMusic iSync Plug-In</title>
		<link>http://pyxx.org/2008/03/18/nokia-5310-xpressmusic-isync-plugin/</link>
		<comments>http://pyxx.org/2008/03/18/nokia-5310-xpressmusic-isync-plugin/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 23:46:30 +0000</pubDate>
		<dc:creator>Sasha Philippov</dc:creator>
		
		<category><![CDATA[Mac]]></category>

		<category><![CDATA[iSync]]></category>

		<category><![CDATA[Nokia 5310 XpressMusic]]></category>

		<guid isPermaLink="false">http://pyxx.org/2008/03/18/nokia-5310-xpressmusic-isync-plugin/</guid>
		<description><![CDATA[iSync Plug-In for Nokia 5310 XpressMusic mobile phone packed as an easy to install Mac OS X package.

Thanks to James Lloyd for a MetaClasses.plist file content.
]]></description>
			<content:encoded><![CDATA[<p><a href="/nokia-5310-xpressmusic-isync-plugin/">iSync Plug-In for Nokia 5310 XpressMusic mobile phone</a> packed as an easy to install <a href="/files/Nokia-5310-XpressMusic-iSync-plugin.dmg">Mac OS X package</a>.</p>

<p>Thanks to <a href="http://www.james-lloyd.com">James Lloyd</a> for a <a href="http://www.james-lloyd.com/scripts/nokia-series-40-isync-plugin/">MetaClasses.plist file content</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pyxx.org/2008/03/18/nokia-5310-xpressmusic-isync-plugin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to round decimal numbers in Python</title>
		<link>http://pyxx.org/2007/10/28/how-to-round-decimal-numbers-in-python/</link>
		<comments>http://pyxx.org/2007/10/28/how-to-round-decimal-numbers-in-python/#comments</comments>
		<pubDate>Sun, 28 Oct 2007 15:20:46 +0000</pubDate>
		<dc:creator>Sasha Philippov</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[decimal]]></category>

		<category><![CDATA[round]]></category>

		<guid isPermaLink="false">http://pyxx.org/2007/10/26/how-to-round-decimal-numbers-in-python-2/</guid>
		<description><![CDATA[How to round Decimal numbers with Symmetric Arithmetic Rounding (as described 
in article &#8220;Rounding&#8221; on wikipedia.org?.

Rounding can be done with 
decimal.Decimal
object&#8217;s quantize method. Use decimal.ROUND&#95;HALF&#95;UP flag to get 
a Symmetric Arithmetic Rounding.

For example:


>>> from decimal import Decimal, ROUND_HALF_UP
>>> Decimal("234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("234.454")
>>> Decimal("234.4534").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("234.453")
>>> Decimal("-234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("-234.454")
>>> Decimal("-234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("-234.454")


So, the &#8220;traditional&#8221; round function will look like this:

from decimal [...]]]></description>
			<content:encoded><![CDATA[<p>How to round Decimal numbers with <em>Symmetric Arithmetic Rounding</em> (as described 
in article &#8220;<a href="http://en.wikipedia.org/wiki/Rounding">Rounding</a>&#8221; on <a href="http://wikipedia.org/">wikipedia.org</a>?.</p>

<p>Rounding can be done with 
<a href="http://docs.python.org/lib/module-decimal.html">decimal</a>.<a href="http://docs.python.org/lib/node127.html">Decimal</a>
object&#8217;s <em>quantize</em> method. Use decimal.ROUND&#95;HALF&#95;UP flag to get 
a <em>Symmetric Arithmetic Rounding</em>.</p>

<p>For example:</p>

<pre>
>>> from decimal import Decimal, ROUND_HALF_UP
>>> Decimal("234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("234.454")
>>> Decimal("234.4534").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("234.453")
>>> Decimal("-234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("-234.454")
>>> Decimal("-234.4535").quantize(Decimal("0.001"), ROUND_HALF_UP)
Decimal("-234.454")
</pre>

<p>So, the &#8220;traditional&#8221; round function will look like this:</p>

<pre>from decimal import Decimal, ROUND_HALF_UP

def round(d, digits=0):
    """
    Symmetric Arithmetic Rounding for decimal numbers

    d       - Decimal number to round
    digits  - number of digits after the point to leave

    For example:
    >>> round(Decimal("234.4536"), 3)
    Decimal("234.454")
    >>> round(Decimal("234.4535"), 3)
    Decimal("234.454")
    >>> round(Decimal("234.4534"), 3)
    Decimal("234.453")
    >>> round(Decimal("-234.4535"), 3)
    Decimal("-234.454")
    >>> round(Decimal("234.4535"), -1)
    Decimal("2.3E+2")
    """
    return d.quantize(Decimal("1") / (Decimal('10') ** digits), ROUND_HALF_UP) 
</pre>
]]></content:encoded>
			<wfw:commentRss>http://pyxx.org/2007/10/28/how-to-round-decimal-numbers-in-python/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Docbook to SCORM Converter is open source</title>
		<link>http://pyxx.org/2007/05/20/docbook-to-scorm-converter-open-source/</link>
		<comments>http://pyxx.org/2007/05/20/docbook-to-scorm-converter-open-source/#comments</comments>
		<pubDate>Sun, 20 May 2007 10:54:27 +0000</pubDate>
		<dc:creator>Sasha Philippov</dc:creator>
		
		<category><![CDATA[Docbook]]></category>

		<category><![CDATA[SCORM]]></category>

		<guid isPermaLink="false">http://pyxx.org/2007/05/20/docbook-to-scorm-converter-open-source/</guid>
		<description><![CDATA[Docbook to SCORM Converter is now open source. It&#8217;s released under 
GNU Lesser General Public License.
Source code and binary files can are available from the project site
at Google Code.

See updated description and usage instructions.
]]></description>
			<content:encoded><![CDATA[<p>Docbook to SCORM Converter is now open source. It&#8217;s released under 
<a href="http://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public License</a>.
Source code and binary files can are available from the <a href="http://code.google.com/p/docbook2scorm/">project site</a>
at <a href="http://code.google.com/">Google Code</a>.</p>

<p>See <a href="http://pyxx.org/convert-docbook-to-scorm/">updated description and usage instructions</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pyxx.org/2007/05/20/docbook-to-scorm-converter-open-source/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
