Photography Backend is a RESTful API server built using the Django Rest Framework (DRF) and token-based authentication using JSON Web Tokens (JWTs). It provides endpoints for managing users, photos, and categories.
- User authentication and registration using JWTs
- CRUD endpoints for managing users, photos, and categories
- Pagination and filtering options for endpoints
- Support for media files (uploaded photos)
- Django
- Django Rest Framework
- MySQL
- JSON Web Tokens (JWTs)
- uWSGI and Nginx (for production deployment)
- Clone the repository:
git clone https://github.com/ECarry/Photography_Backend.git- Install the dependencies:
pip install -r requirements.txt- Create a MySQL database and update the DATABASES setting in settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': '<your-database-name>',
'USER': '<your-database-user>',
'PASSWORD': '<your-database-password>',
'HOST': '<your-database-host>',
'PORT': '<your-database-port>',
}
}- Run database migrations:
python manage.py migrate- Create a superuser account:
python manage.py createsuperuser- Start the development server:
python manage.py runserver- Access the API at http://localhost:8000/api/.
- POST
/api/token/: obtain a JWT token by providing valid credentials - POST
/api/token/refresh/: refresh a JWT token
- GET
/api/photos/: retrieve a list of photos - POST
/api/photos/: upload a new photo - GET
/api/photos/{id}/: retrieve a single photo by ID - PUT
/api/photos/{id}/: update a single photo by ID - DELETE
/api/photos/{id}/: delete a single photo by ID
- GET
/api/category/: retrieve a list of categories - POST
/api/category/: create a new category - GET
/api/category/{id}/: retrieve a single category by ID - PUT
/api/category/{id}/: update a single category by ID - DELETE
/api/category/{id}/: delete a single category by ID
To deploy the application in a production environment, follow these steps:
- Install uWSGI and Nginx on your server.
- Configure Nginx to proxy requests to the uWSGI server.
- Update the ALLOWED_HOSTS setting in settings.py to include your server's domain name.
- Collect static files using python manage.py collectstatic.
- Start the uWSGI server with the following command:
uwsgi --http :8000 --module <path-to-uwsgi-config-file>Contributions to the project are welcome. If you find a bug or have a feature request, please create an issue on the repository. If you would like to contribute code, please create a pull request and include a detailed description of your changes.
This project is licensed under the MIT License - see the LICENSE file for details.