djangosnippets.org: Latest snippets tagged with 'rename'https://djangosnippets.org/tags/rename/2009-08-25T08:10:16.311591-05:00Auto-rename duplicate fields
2009-08-25T08:10:16.311591-05:00christian.oudardhttps://djangosnippets.org/snippets/1699/<p>This is useful to run before you add a unique key to a character field that has duplicates in it. It just adds numbers to the end of the contents, so they will be unique.</p>
<p>It takes a model class and a field name. The model class can be a …</p>
Freely redistributableUse the primary key in FileField and ImageField filenames
2008-10-12T13:11:10.251396-05:00exogenhttps://djangosnippets.org/snippets/1129/<p>Sometimes it is desirable to use values like the primary key when naming <code>FileField</code> and <code>ImageField</code> files, but such values are only available after saving the model instance. This abstract class implements a two-phase save in order to make this case easy. See the example in the docstring.
</p>
<p>Another solution …</p>
Freely redistributableImage Standarization
2008-04-15T16:06:28.145749-05:00garcia_marchttps://djangosnippets.org/snippets/707/<p>Standarization of image fields (for being used when saving models). Automatically creates thumbnail. Change image name to /path/to/images/<my_field>-<id>.<ext>. Resize image and thumbnail to specified size (optionally can crop image to force size).</p>
Freely redistributable