ephes / django-filepond

Endpoints that can be used by filepond.
Other
3 stars 1 forks source link

Complete tutorial is needed #1

Open kwhandy opened 5 years ago

kwhandy commented 5 years ago

The documentation doesn't exist, can you please tell me how to use it wit regular modelform? I mean without ajax, drf, graphql or something similar to that. I need to configure that with django default way only but your docs just include how to install only.

I really appreciate your help

ephes commented 5 years ago

You can just use the UploadCreateView from filepond.views with UploadForm from filepond.forms. This will save your upload in Upload from filepond.models. In fact, every upload should be stored there so that django-filepond knows about all uploads and is the central app to manage them.

But the most frequent use case is probably that some other (your) django app wants to use django-filepond to store uploads. Your app then should declare an upload_handler function in __init__.py that defines which kind of upload should go to which model field (yes, that's possible :)). You can even specify the field the user that uploaded the file should be stored to. The form for that model has to be dynamically created by the get_model_form (I know looks a bit confusing). In your upload post request you have to set the "app_name" parameter to specify which app should receive the upload (which upload_handler should be called). The Upload model from django-filepond then links back to that target model via a generic foreign key. Here's an example on how I use it in django-cast:

https://github.com/ephes/django-cast/blob/develop/cast/__init__.py

Oh, did you see the testapp?

https://github.com/ephes/django-filepond/tree/develop/testapp

HTH, HAND jochen