<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Improved UUIDField in Django</title>
	<atom:link href="http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html</link>
	<description>A blog about Django, JavaScript, CSS, and general web development.</description>
	<lastBuildDate>Tue, 09 Mar 2010 21:59:12 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: David Underhill</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-22005</link>
		<dc:creator>David Underhill</dc:creator>
		<pubDate>Thu, 28 Jan 2010 20:06:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-22005</guid>
		<description>Thanks for sharing - this code works well for me!  I&#039;m also experimenting with just using a regular CharField and auto-populating the value using a post_init signal handler.</description>
		<content:encoded><![CDATA[<p>Thanks for sharing &#8211; this code works well for me!  I&#8217;m also experimenting with just using a regular CharField and auto-populating the value using a post_init signal handler.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EdMenendez</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20832</link>
		<dc:creator>EdMenendez</dc:creator>
		<pubDate>Fri, 26 Jun 2009 00:54:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20832</guid>
		<description>I&#039;m using the following for Postgres 8.2.

    def db_type(self):
        return &#039;character varying(32)&#039;

    def get_db_prep_value(self, value):
        if not value: return
        if not isinstance(value, uuid.UUID):
            value = uuid.UUID(value)
        return value.hex #unicode(value)</description>
		<content:encoded><![CDATA[<p>I&#8217;m using the following for Postgres 8.2.</p>
<p>    def db_type(self):<br />
        return &#8216;character varying(32)&#8217;</p>
<p>    def get_db_prep_value(self, value):<br />
        if not value: return<br />
        if not isinstance(value, uuid.UUID):<br />
            value = uuid.UUID(value)<br />
        return value.hex #unicode(value)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HenrikV</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20729</link>
		<dc:creator>HenrikV</dc:creator>
		<pubDate>Tue, 24 Mar 2009 23:08:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20729</guid>
		<description>I originally started out using UUID as primary keys on my old project. I had some trouble   with uuid imports in Python 2.5

I seem to recall that if you for some reason try to import uuid in settings.py python will silently crash.

Did you have any trouble like that?</description>
		<content:encoded><![CDATA[<p>I originally started out using UUID as primary keys on my old project. I had some trouble   with uuid imports in Python 2.5</p>
<p>I seem to recall that if you for some reason try to import uuid in settings.py python will silently crash.</p>
<p>Did you have any trouble like that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20681</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Thu, 12 Mar 2009 03:57:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20681</guid>
		<description>Ah, sorry, I need varchar(length) on Postgres... but it supports uuid anyway, so I&#039;m using --- 

    def db_type(self):
        return &#039;uuid&#039;

Although it seems (for me, at least) that get_db_prep_value assumes it&#039;s dealing with a uuid.UUID, when in the admin change view it&#039;s a unicode (and postgresql and other DBs seemingly want a 36 char string anyway...) so I&#039;m using the following,

    def get_db_prep_value(self, value):
        if not value: return
        print type(value)
        if isinstance(value, uuid.UUID):
            return unicode(value)
        return value</description>
		<content:encoded><![CDATA[<p>Ah, sorry, I need varchar(length) on Postgres&#8230; but it supports uuid anyway, so I&#8217;m using &#8212; </p>
<p>    def db_type(self):<br />
        return &#8216;uuid&#8217;</p>
<p>Although it seems (for me, at least) that get_db_prep_value assumes it&#8217;s dealing with a uuid.UUID, when in the admin change view it&#8217;s a unicode (and postgresql and other DBs seemingly want a 36 char string anyway&#8230;) so I&#8217;m using the following,</p>
<p>    def get_db_prep_value(self, value):<br />
        if not value: return<br />
        print type(value)<br />
        if isinstance(value, uuid.UUID):<br />
            return unicode(value)<br />
        return value</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20680</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Thu, 12 Mar 2009 02:52:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20680</guid>
		<description>Yeah, for some reason my __init__ doesn&#039;t seem to be called in trunk.

In other words with,

class MyModel(models.Model):
    uuid = UUIDField(primary_key=True, db_index=True, auto=True)

I get a character(1) in my DB (postgresql) and thus everything fails... so weird.  I can even import the class and UUIDField() with a 1/0 in the init and nothing happens?  I assume this has to do with the metaclass or something?</description>
		<content:encoded><![CDATA[<p>Yeah, for some reason my __init__ doesn&#8217;t seem to be called in trunk.</p>
<p>In other words with,</p>
<p>class MyModel(models.Model):<br />
    uuid = UUIDField(primary_key=True, db_index=True, auto=True)</p>
<p>I get a character(1) in my DB (postgresql) and thus everything fails&#8230; so weird.  I can even import the class and UUIDField() with a 1/0 in the init and nothing happens?  I assume this has to do with the metaclass or something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20679</link>
		<dc:creator>David</dc:creator>
		<pubDate>Tue, 10 Mar 2009 19:01:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20679</guid>
		<description>Sorry the original code has been fixed.

However, there seems to be an issue in Django where it&#039;s not quite passing in UUID instances everywhere. I&#039;m currently looking into why.</description>
		<content:encoded><![CDATA[<p>Sorry the original code has been fixed.</p>
<p>However, there seems to be an issue in Django where it&#8217;s not quite passing in UUID instances everywhere. I&#8217;m currently looking into why.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20672</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Sun, 08 Mar 2009 16:42:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20672</guid>
		<description>What is the variable &quot;name&quot; here (undefined)?

elif version in (3, 5):
    self.namespace, self.name = namespace, name</description>
		<content:encoded><![CDATA[<p>What is the variable &#8220;name&#8221; here (undefined)?</p>
<p>elif version in (3, 5):<br />
    self.namespace, self.name = namespace, name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: trbs</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20661</link>
		<dc:creator>trbs</dc:creator>
		<pubDate>Tue, 03 Mar 2009 10:15:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20661</guid>
		<description>Any patched for useful improvements to the UUIDField in django-extensions would be much appreciated :)</description>
		<content:encoded><![CDATA[<p>Any patched for useful improvements to the UUIDField in django-extensions would be much appreciated <img src='http://www.davidcramer.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: skabber</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20658</link>
		<dc:creator>skabber</dc:creator>
		<pubDate>Mon, 02 Mar 2009 18:36:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20658</guid>
		<description>Very nice.  Do you know how this compares to the UUIDField in django extensions?

http://code.google.com/p/django-command-extensions/source/browse/trunk/django_extensions/db/fields/__init__.py</description>
		<content:encoded><![CDATA[<p>Very nice.  Do you know how this compares to the UUIDField in django extensions?</p>
<p><a href="http://code.google.com/p/django-command-extensions/source/browse/trunk/django_extensions/db/fields/__init__.py" rel="nofollow">http://code.google.com/p/django-command-extensions/source/browse/trunk/django_extensions/db/fields/__init__.py</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brantley Harris</title>
		<link>http://www.davidcramer.net/code/420/improved-uuidfield-in-django.html/comment-page-1#comment-20657</link>
		<dc:creator>Brantley Harris</dc:creator>
		<pubDate>Mon, 02 Mar 2009 16:24:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=420#comment-20657</guid>
		<description>Careful, the uuid module is not in 2.4 or below.</description>
		<content:encoded><![CDATA[<p>Careful, the uuid module is not in 2.4 or below.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
