Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

A Django app providing simple rest attachment upload and download.

Project description

Django Rest Attachment

Django Free Attachment is a Django app to provide a simple attachment service independent of any other model.

Detailed documentation is in the "docs" directory.

Quick start

  1. Setup environment
mkdir django
cd django
python -m venv .venv
source .venv/bin/activate

# Create requirements.txt file
cat <<EOF > requirements.txt

pip install -r requirements.txt
  1. Start Project
django-admin startproject proj
  1. Add "attachment" to your INSTALLED_APPS setting like this::
  1. Add Media settings, if you have done this, ignore this step
MEDIA_DIR = os.path.join(BASE_DIR, "media")

MEDIA_URL = '/media/'
  1. add to pro folder (the save folder with

from rest_framework import routers
from attachment.viewsets import AttachmentViewSet

router = routers.SimpleRouter()
router.register(r'attachment', AttachmentViewSet, basename='attachment')
  1. Include the attachment and api URLconf in your project like this::
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from .routers import router

urlpatterns = [
  path('api/', include(router.urls), name='api'),
  path('attachment/', include('attachment.urls'), name='attachment'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  1. Run python migrate to create the polls models.

  2. Add superuser

python createsuperuser
python runserver
  1. Start the development server and visit


  1. Visit to upload a attachment from admin

  2. Using Postman to post a REST request:

  • add X-CSRFToken to header

  • add session id to Postman Cookies

Postman can automatically extract session from chrome browser refer Postman Doc



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-rest-attachment, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size django-rest-attachment-0.2.1.tar.gz (410.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page