Friday, March 29, 2019

Nameless FileField

I think the current FileField is nice for some use cases,
but for other use cases it is too complicated.

Example:

class MyProfile(models.Model):
    picture = models.FileField()


If profile of user "foo" uses "foo.jpg" as picture,
and user "bar" uses "foo.jpg", too. Then
the profile picture of "bar" will overwrite the picture
of "foo.jpg".

I know that there are ways to work-around this.

But why not provide a more convenient way in future
releases of Django?

But maybe I am missing something.

Wouldn't it be nice, if there would be a nameless FileField?

I don't want to care about the name of the file. It can
be a uuid or other random data.

If you want to store some data like a blob, like BinaryField.
But, I don't want to store the blob in the
database, like BinaryField does. I would like to use a plugable storage.

Up to now you can't easily use FileField in create() or get_or_create().

It would be nice if you could use a nameless FileField like this:

    MyProfile.objects.create(picture=b'binarydata...')


What do you think about this idea?

Is it worth talking to django-developers, or is there already a solution,
which I just do not know up to now?

Regards,
  Thomas Güttler

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/560930c8-ce69-4af9-8128-7f0043612345%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment