A Django-based project designed to serve course-related APIs using Django Rest Framework (DRF). It supports a set of APIs that expose course categories, courses, sessions, and concepts, with all course data populated by the Django admin panel.
- Course Management: Define course categories, courses, and sessions.
- API Powered by DRF: Expose data through REST APIs with rate limiting.
- File Upload Support: Upload and serve media files such as thumbnails for courses and sessions.
- Admin Panel: Content creation and management is handled through the Django admin interface.
Make sure to set the following environment variables in your .env file:
SECRET_KEY: Django secret key for your application.ADMIN_URL: Custom URL for accessing the Django admin panel.DB_ENGINE: Set tomysqlso Django connects to the managed MySQL instance.DB_NAME,DB_USER,DB_PASSWORD: Credentials for your MySQL database.DB_HOST(optional): Defaults to127.0.0.1. Use the host provided by your MySQL provider.DB_PORT(optional): Defaults to3306.
- Clone the Repository:
git clone <repository-url>
- Create Virtual Environment:
python -m venv venv
source venv/bin/activate # For Linux/macOS
venv\Scripts\activate # For Windows- Install Dependencies
pip install -r requirements.txt- Run Migrations
python manage.py migrate- Create Superuser
python manage.py createsuperuser- Run the Development Serve
python manage.py runserverNavigate to the admin URL (set via ADMIN_URL in your .env file or use the default /admin/).
- Categories:
/api/categories/ - Courses:
/api/courses/ - Sessions:
/api/sessions/ - Concepts:
/api/concepts/
Allow CORS requests from your frontend (e.g., GitHub Pages) by setting the allowed origins in CORS_ALLOWED_ORIGINS in settings.py.
CORS_ALLOWED_ORIGINS = [
"https://youralloweddomain.com",
]Anonymous users are limited to 1000 requests per minute, while authenticated users are limited to 100 requests per day.
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_CLASSES': [
'rest_framework.throttling.AnonRateThrottle',
'rest_framework.throttling.UserRateThrottle'
],
'DEFAULT_THROTTLE_RATES': {
'anon': '1000/min',
'user': '100/day'
}
}Uploaded media files are stored in the media/ directory. Make sure the MEDIA_ROOT and MEDIA_URL are configured correctly in settings.py.
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'This project is licensed under the MIT License. See the LICENSE file for details.