Django Generic File
Project description
Django Generic File
===================
A Generic File Model for all kind of file attachment with AJAX fileupload and drag & drop feature.
Installation
------------
pip install django-generic-file
Usage
-----
Add "genericfile" to your INSTALLED_APPS.
Include following static files in your template
<link rel="stylesheet" type="text/css" href="{% static 'genericfile/genericfile.css' %}">
<script src="{% static 'genericfile/genericfile.js' %}"></script>
At the top of your template load our template tags
{% load genericfiletags %}
Then to render your form
------------------------
1. In Add Form (where object is not yet created)
<form action='.' method='post'>
{% csrf_token %}
{{ form }}
{% get_genericfile_form %}
<button type='submit' class="btn blue">Submit</button>
</form>
2. In Edit Form (where object is known)
<form action='.' method='post'>
{% csrf_token %}
{{ form }}
{% get_genericfile_form host_object=form.instance %}
<button type='submit' class="btn blue">Submit</button>
</form>
To get the list of files in Details view
----------------------------------------
{% get_genericfile_list host_object=object as attachments %}
<ul>
{% for file in attachments %}
<li><a href="{{file.attachment.url}}" target="_blank">{{file.get_name}}</a></li>
{% empty %}
<li>No files found</li>
{% endfor %}
</ul>
Additional Requirements
-----------------------
Include following in you html file
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
===================
A Generic File Model for all kind of file attachment with AJAX fileupload and drag & drop feature.
Installation
------------
pip install django-generic-file
Usage
-----
Add "genericfile" to your INSTALLED_APPS.
Include following static files in your template
<link rel="stylesheet" type="text/css" href="{% static 'genericfile/genericfile.css' %}">
<script src="{% static 'genericfile/genericfile.js' %}"></script>
At the top of your template load our template tags
{% load genericfiletags %}
Then to render your form
------------------------
1. In Add Form (where object is not yet created)
<form action='.' method='post'>
{% csrf_token %}
{{ form }}
{% get_genericfile_form %}
<button type='submit' class="btn blue">Submit</button>
</form>
2. In Edit Form (where object is known)
<form action='.' method='post'>
{% csrf_token %}
{{ form }}
{% get_genericfile_form host_object=form.instance %}
<button type='submit' class="btn blue">Submit</button>
</form>
To get the list of files in Details view
----------------------------------------
{% get_genericfile_list host_object=object as attachments %}
<ul>
{% for file in attachments %}
<li><a href="{{file.attachment.url}}" target="_blank">{{file.get_name}}</a></li>
{% empty %}
<li>No files found</li>
{% endfor %}
</ul>
Additional Requirements
-----------------------
Include following in you html file
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-generic-file-0.0.1.zip
(18.1 kB
view hashes)
Built Distribution
django-generic-file-0.0.1.win32.exe
(212.0 kB
view hashes)
Close
Hashes for django-generic-file-0.0.1.win32.exe
Algorithm | Hash digest | |
---|---|---|
SHA256 | 370f30a95da941f2381081fc523279a3434206cfc3a74867d8ad6a89c99fe0c5 |
|
MD5 | 99d75afee5554bcedb2ae4f1e406d18c |
|
BLAKE2b-256 | 48a51af62c4bfd9bc41192b169ec34554bae04bd28ea8c58c61395c2c8cf14d4 |