Attachments
Links
Install
Install the library:
pip install django-attachments
Add
'django.core.context_processors.request',
toTEMPLATE_CONTEXT_PROCESSORS
insettings.py
.If
TEMPLATE_CONTEXT_PROCESSORS
does not exist, add the following:TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.auth', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.request', )
Add
attachments
toINSTALLED_APPS
insettings.py
:INSTALLED_APPS = ( ... 'attachments', )
Add the following to your
urls.py
:(r'^attachments/', include('attachments.urls')),
Synchronise the database:
./manage.py syncdb
Sample
Sample template code:
{% load attachments_tags %}
{% get_attachments_for article %}
{% if attachments %}
<h3>Attachments</h3>
<ul>
{% for attachment in attachments %}
<li>
<a href=" attachment.attachment_file.url "> attachment.filename </a>
{% attachment_delete_link attachment %}
</li>
{% endfor %}
</ul>
{% endif %}
{% attachment_form article %}
Note: The user will need the following permissions to gain full access:
|
add attachments. |
|
delete your own attachments. |
|
delete other users attachments. |