FileField in custom field

33 views
Skip to first unread message

Simonas Pilkauskas

unread,
Nov 5, 2019, 8:02:31 AM11/5/19
to Django users
Hello,
I want to setup a Model like this, but apparently FileField in custom field doesn't work out of box (when trying to save, I get the error "can't adapt type 'TemporaryUploadedFile'"). FileField, which is directly in Model, works fine.
I've tried what came to my mind, but I'm relatively new to Django and can't figure out myself.
Could anyone help me?

Integr@te System

unread,
Nov 5, 2019, 8:42:38 AM11/5/19
to django...@googlegroups.com
Hi Issuer,

please see:
In your settings file, you’ll need to define MEDIA_ROOT as the full path to a directory where you’d like Django to store uploaded files. (For performance, these files are not stored in the database.) Define MEDIA_URL as the base public URL of that directory. Make sure that this directory is writable by the Web server’s user account.


And more check in this content.



--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c34d85b3-78d6-4d89-804f-b1cf2f77c2e5%40googlegroups.com.

Simonas Pilkauskas

unread,
Nov 5, 2019, 12:42:35 PM11/5/19
to Django users
I think you misread my question. FileFields in Models work for me just fine (I have already defined MEDIA_ROOT and figured out directory stuff).
However, I need to have FileField in Field and that Field in Model, but having such hierarchy throws error.

2019 m. lapkritis 5 d., antradienis 15:42:38 UTC+2, Integr@te System rašė:
Hi Issuer,

please see:
In your settings file, you’ll need to define MEDIA_ROOT as the full path to a directory where you’d like Django to store uploaded files. (For performance, these files are not stored in the database.) Define MEDIA_URL as the base public URL of that directory. Make sure that this directory is writable by the Web server’s user account.


And more check in this content.



On Tue, Nov 5, 2019, 20:01 Simonas Pilkauskas <simonas....@hotmail.com> wrote:
Hello,
I want to setup a Model like this, but apparently FileField in custom field doesn't work out of box (when trying to save, I get the error "can't adapt type 'TemporaryUploadedFile'"). FileField, which is directly in Model, works fine.
I've tried what came to my mind, but I'm relatively new to Django and can't figure out myself.
Could anyone help me?

--
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...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages