<?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"
	>
<channel>
	<title>Comments on: File Fields without Renaming Duplicates</title>
	<atom:link href="http://www.davidcramer.net/code/118/file-fields-without-renaming-duplicates.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.davidcramer.net/code/118/file-fields-without-renaming-duplicates.html</link>
	<description>A blog about Django, JavaScript, CSS, and general web development.</description>
	<pubDate>Fri, 25 Jul 2008 10:46:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: David</title>
		<link>http://www.davidcramer.net/code/118/file-fields-without-renaming-duplicates.html#comment-19792</link>
		<dc:creator>David</dc:creator>
		<pubDate>Fri, 11 Apr 2008 22:12:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=118#comment-19792</guid>
		<description>Mmm nice.

I ended up reworking my filefield's and just using file = blah and calling .save(). The timestamp stuff was still causing too many directories, and I had to base it off the an id (similar to how we had done it at Curse).

It ends up being screenshots/%s/%s % divmod(id, 1000)</description>
		<content:encoded><![CDATA[<p>Mmm nice.</p>
<p>I ended up reworking my filefield&#8217;s and just using file = blah and calling .save(). The timestamp stuff was still causing too many directories, and I had to base it off the an id (similar to how we had done it at Curse).</p>
<p>It ends up being screenshots/%s/%s % divmod(id, 1000)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gulopine</title>
		<link>http://www.davidcramer.net/code/118/file-fields-without-renaming-duplicates.html#comment-19791</link>
		<dc:creator>Gulopine</dc:creator>
		<pubDate>Fri, 11 Apr 2008 22:10:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.davidcramer.net/?p=118#comment-19791</guid>
		<description>This is one of many reasons I'm really looking forward to ticket #5361 being checked into trunk as soon as possible. What you're working toward here would be quite simple (my apologies if the code doesn't look right.

from django.core.filestorage.filesystem import FileSystemStorage

class UsefulFileStorage(FileSystemStorage):
    def get_available_filename(self, filename):
        # Leave the filename unmodified
        return filename

Then when you want to use it in a model:

from django.db import models
from myapp.storage import UsefulFileStorage

class MyModel(models.Model):
    screenshot = models.ImageField(upload_to="screenshots/%s/%s/", storage=UsefulFileStorage(), blank=True, null=True)</description>
		<content:encoded><![CDATA[<p>This is one of many reasons I&#8217;m really looking forward to ticket #5361 being checked into trunk as soon as possible. What you&#8217;re working toward here would be quite simple (my apologies if the code doesn&#8217;t look right.</p>
<p>from django.core.filestorage.filesystem import FileSystemStorage</p>
<p>class UsefulFileStorage(FileSystemStorage):<br />
    def get_available_filename(self, filename):<br />
        # Leave the filename unmodified<br />
        return filename</p>
<p>Then when you want to use it in a model:</p>
<p>from django.db import models<br />
from myapp.storage import UsefulFileStorage</p>
<p>class MyModel(models.Model):<br />
    screenshot = models.ImageField(upload_to=&#8221;screenshots/%s/%s/&#8221;, storage=UsefulFileStorage(), blank=True, null=True)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
