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! ๐