A Django REST API for managing IPO (Initial Public Offering) data with comprehensive filtering, search, and CRUD operations.
- Python 3.8 or higher
- pip (Python package manager)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtcp .env.example .env
# Edit .env file with your configurationpython setup_backend.pypython create_sample_data.pypython manage.py runserverThe API will be available at: http://127.0.0.1:8000/api/
GET /api/ipo/- List all IPOs (with filtering & search)POST /api/ipo/- Create new IPOGET /api/ipo/{id}/- Get IPO detailsPUT /api/ipo/{id}/- Update IPODELETE /api/ipo/{id}/- Delete IPO
GET /api/ipo/upcoming/- Get upcoming IPOsGET /api/ipo/ongoing/- Get ongoing IPOsGET /api/ipo/listed/- Get listed IPOsGET /api/ipo/search/?q=term- Search IPOsGET /api/ipo/stats/- Get statistics
- Filter by status, dates, price ranges
- Search by company name and issue type
- Sort by any field (ascending/descending)
- Pagination support
- Complete CRUD operations
- File uploads (logos, documents)
- Automatic calculation of returns
- Data validation
- Django admin at
/admin/ - Easy data management
- Bulk operations
curl http://127.0.0.1:8000/api/ipo/curl http://127.0.0.1:8000/api/ipo/upcoming/curl "http://127.0.0.1:8000/api/ipo/search/?q=tech"curl "http://127.0.0.1:8000/api/ipo/?status=listed&open_date_from=2024-01-01"curl -X POST http://127.0.0.1:8000/api/ipo/ \
-H "Content-Type: application/json" \
-d '{
"company_name": "New Tech Corp",
"price_band": "βΉ200-250",
"open_date": "2024-12-20",
"close_date": "2024-12-23",
"issue_size": "βΉ1000 Cr",
"issue_type": "Fresh Issue",
"status": "upcoming",
"ipo_price": 225.0
}'manage.py # π§ Django's command-line tool (run migrations, start server)
requirements.txt # π¦ List of Python packages to install
.env # π Secret settings (passwords, keys) - don't share!
ipo_backend/
βββ __init__.py # π Makes this a Python package (usually empty)
βββ settings.py # βοΈ Main configuration (database, apps, security)
βββ urls.py # π£οΈ Main URL routing (which URLs go where)
βββ wsgi.py # π Web server configuration (for deployment)
βββ asgi.py # β‘ Async server configuration (for real-time features)
ipo_app/
βββ __init__.py # π Makes this a Python package
βββ models.py # ποΈ Database structure (IPO data fields)
βββ views.py # π― Business logic (what happens when API is called)
βββ urls.py # π£οΈ App-specific URL routing
βββ serializers.py # π Convert data between Python and JSON
βββ admin.py # π¨βπΌ Django admin panel configuration
βββ apps.py # π± App configuration
βββ filters.py # π Search and filter logic
- Models = Database tables (what data looks like)
- Views = Controllers (what happens when someone visits URL)
- URLs = Routes (which URL calls which view)
- Serializers = Data formatters (Python β JSON)
- Admin = Built-in management interface
1. User visits URL β 2. urls.py finds matching view β 3. views.py processes request
β
4. Response sent back β 5. Serializer formats data β 6. models.py gets data from database
Example: User visits /api/ipo/
ipo_backend/urls.pyβ routes toipo_app/urls.pyipo_app/urls.pyβ callsIPOViewSetinviews.pyviews.pyβ gets IPO data frommodels.pyserializers.pyβ converts data to JSON- JSON response sent to user
ipo_backend/
βββ ipo_backend/ # Main Django project
β βββ settings.py # Django settings
β βββ urls.py # Main URL configuration
β βββ ...
βββ ipo_app/ # IPO application
β βββ models.py # Data models
β βββ serializers.py # API serializers
β βββ views.py # API views
β βββ urls.py # App URLs
β βββ admin.py # Admin configuration
β βββ filters.py # Custom filters
βββ manage.py # Django management script
βββ requirements.txt # Python dependencies
βββ ...
python manage.py test# Start development server
python manage.py runserver
# Create migrations (after changing models.py)
python manage.py makemigrations
# Apply migrations to database
python manage.py migrate
# Create admin user
python manage.py createsuperuser
# Open Django shell (interactive Python with Django)
python manage.py shell
# Check for issues
python manage.py check
# Collect static files (for production)
python manage.py collectstaticpython manage.py testpython manage.py makemigrations
python manage.py migratepython manage.py createsuperuserSECRET_KEY=your-secret-key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
- Default: SQLite (for development)
- Production: PostgreSQL recommended
- API Documentation
- Django REST Framework: https://www.django-rest-framework.org/
- Set
DEBUG=False - Configure proper
SECRET_KEY - Set up PostgreSQL database
- Configure static file serving
- Set up proper CORS origins
- Use environment variables for sensitive data
Create Dockerfile and docker-compose.yml for containerized deployment.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.
Happy coding! π