Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve README.md #46

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ django-filepicker

A django plugin to make integrating with Filepicker.io even easier

##Installation
## Installation

1. Install the python package:

Expand Down Expand Up @@ -51,36 +51,40 @@ A django plugin to make integrating with Filepicker.io even easier
</form>
</body>

##Demo
## Demo
To see how all the pieces come together, see the example code in demo/, which you can run with the standard
`python manage.py runserver` command

###models.py
import django_filepicker
class TestModel(models.Model):
#FPFileField is a field that will render as a filepicker dragdrop widget, but
#When accessed will provide a File-like interface (so you can do fpfile.read(), for instance)
fpfile = django_filepicker.models.FPFileField(upload_to='uploads')

###views.py
#building the form - automagically turns the uploaded fpurl into a File object
form = models.TestModelForm(request.POST, request.FILES)
if form.is_valid():
#Save will read the data and upload it to the location defined in TestModel
form.save()

Be sure to also provide your Filepicker.io api key, either as a parameter to the FPFileField or in settings.py as `FILEPICKER_API_KEY`

##Components
###Models
`python manage.py runserver` command.

### models.py
```python
import django_filepicker
class TestModel(models.Model):
#FPFileField is a field that will render as a filepicker dragdrop widget, but
#When accessed will provide a File-like interface (so you can do fpfile.read(), for instance)
fpfile = django_filepicker.models.FPFileField(upload_to='uploads')
```

### views.py
```python
#building the form - automagically turns the uploaded fpurl into a File object
form = models.TestModelForm(request.POST, request.FILES)
if form.is_valid():
#Save will read the data and upload it to the location defined in TestModel
form.save()
```

Be sure to also provide your Filepicker.io api key, either as a parameter to the FPFileField or in settings.py as `FILEPICKER_API_KEY`.

## Components
### Models
The filepicker django library defines the `FPFileField` model field so you can get all the benefits of using Filepicker.io as a drop-in replacement for the standard django `FileField`. No need to change any of your view logic.

###Forms
Similarly with the `FPFileField` for models, the filepicker django library defines a `FPFileField` for forms as well, that likewise serves as a drop-in replacement for the standard django `FileField`. There is also the `FPUrlField` if you want to store the Filepicker.io URL instead
### Forms
Similarly with the `FPFileField` for models, the filepicker django library defines a `FPFileField` for forms as well, that likewise serves as a drop-in replacement for the standard django `FileField`. There is also the `FPUrlField` if you want to store the Filepicker.io URL instead.

###Middleware
Also included is a middleware library that will take any Filepicker.io urls passed to the server, download the contents, and place the result in request.FILES. This way, you can keep your backend code for handling file uploads the same as before while adding all the front-end magic that Filepicker.io provides
### Middleware
Also included is a middleware library that will take any Filepicker.io urls passed to the server, download the contents, and place the result in request.FILES. This way, you can keep your backend code for handling file uploads the same as before while adding all the front-end magic that Filepicker.io provides.

If you have any questions, don't hesitate to reach out at [[email protected]](mailto:[email protected]). For more information, see [https://filepicker.io](https://www.filepicker.io)
If you have any questions, don't hesitate to reach out at [[email protected]](mailto:[email protected]). For more information, see [https://filepicker.io](https://www.filepicker.io).

Open-sourced under the MIT License. Pull requests encouraged!