A Django-based web application for managing folders and files with support for uploads, allowed file types, and API endpoints for AJAX/REST access.
- Create and manage folders with type restrictions (e.g., PDF-only folders).
- Upload files to folders with secure filename handling.
- Browse folder contents through a web interface.
- REST API endpoints for AJAX/JS clients.
- Authentication via Django sessions (forms) and JWT tokens (API).
- Optional encryption support using
cryptography.Fernet.
- Python 3.10+
- pip (Python package manager)
- Git
- (macOS) Xcode Command Line Tools (for building some packages)
- (optional) Homebrew for installing dependencies like Rust
git clone https://github.com/preetgupta-32/folder-manager-iudx.git
cd folder-manager-iudxpython3 -m venv venv
source venv/bin/activate # macOS/Linux
# .\venv\Scripts\Activate.ps1 # Windows PowerShellpip install --upgrade pip
pip install "django>=4.2" djangorestframework werkzeug PyJWT cryptography python-dotenv pillow requests django-cors-headersIf you see ModuleNotFoundError for any library, install it via:
pip install <package-name>python manage.py makemigrations
python manage.py migratepython manage.py createsuperuserFollow the prompts to set username, email, and password.
python manage.py runserverThe site will be available at: http://127.0.0.1:8000/
python manage.py collectstaticfolder-manager-iudx/
├── files/ # Main app with models, views, APIs
│ ├── models.py # Folder and File models
│ ├── views.py # Template-based views
│ ├── api.py # REST API views (return JSON)
│ ├── urls.py # URLs for views
│ ├── api_urls.py # URLs for API endpoints
├── temp_site/ # Django project settings & URLs
├── static/ # CSS, JS files
├── templates/ # HTML templates
├── manage.py # Django entry point
└── ...
- Navigate to
/→ list folders and upload files. - Create new folders by filling in the form.
- Upload files directly to selected folders.
- Visit
/folder-detail/<id>/to see files in a folder.
Common endpoints (defined in files/api_urls.py):
GET /api/folders/→ list folders (JSON)POST /api/folders/→ create folder (expects JSON{name, parent, allowed_type})GET /api/folders/<id>/→ folder detailsPOST /api/files/→ upload fileDELETE /api/files/<id>/→ delete filePOST /api/login/→ obtain JWT token
Example AJAX call (JavaScript):
fetch('/api/folders/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrftoken,
'Authorization': `Bearer ${jwtToken}`
},
body: JSON.stringify({ name: "New Folder", parent: 1, allowed_type: "pdf" })
})
.then(res => res.json())
.then(data => console.log("Created folder:", data));Set via .env file or shell export:
export DJANGO_SECRET_KEY="your_dev_secret"
export DEBUG=True
export DATABASE_URL="sqlite:///db.sqlite3"- Do not commit your virtual environment (
venv/) to Git. - Add sensitive values (
.env, keys, database passwords) to.gitignore. - Use
pip freeze > requirements.txtto record dependencies for collaborators. - The development server is not for production. For deployment, use WSGI/ASGI with Gunicorn, Daphne, or Uvicorn behind Nginx.
-
ModuleNotFoundError: Install the missing library withpip install <name>. -
Cryptography build errors (macOS):
xcode-select --install brew install rust pip install cryptography
-
Database errors: Delete
db.sqlite3(local dev only), re-run migrations. -
Static file 404: Run
python manage.py collectstatic.
This project inherits the license of the IUDX ecosystem. Please check the upstream repository for licensing terms.
- Fork the repo
- Create a feature branch:
git checkout -b feature/my-feature - Commit changes:
git commit -m "Add feature" - Push branch:
git push origin feature/my-feature - Open a Pull Request