Re: FileField with UUID filename

2016-09-06 Thread Jon Ribbens
On Tuesday, 6 September 2016 17:05:39 UTC+1, Tim Graham wrote: > > See https://code.djangoproject.com/ticket/4345 for the ticket that > disallowed primary_key/unique on FileField. > I've now opened a new ticket #27188 to suggest reversing this change ;-) > You can write a custom field to get F

Re: FileField with UUID filename

2016-09-06 Thread Tim Graham
See https://code.djangoproject.com/ticket/4345 for the ticket that disallowed primary_key/unique on FileField. You can write a custom field to get FileField to use a UUID in the database (and likely also lift the other restrictions you want to bypass). On Sunday, September 4, 2016 at 11:54:06 A

FileField with UUID filename

2016-09-04 Thread Jon Ribbens
I have a model which basically just represents a file. I want to use a UUID as the filename. I could do the following: def _get_filename(instance, filename): return str(uuid.uuid4()) class File(Model): content = FileField(db_index=True, upload_to=_get_filename) file