Step-by-step guide for building and maintaining a Django travel planning application with weather integration, following project-specific conventions and best practices.
This skill provides comprehensive guidance for developing a Django-based travel planning application with itinerary management and weather integration. Follow these instructions when implementing features or making changes to the codebase.
**Project Type:** Django web application for trip planning
**Core Features:** Itinerary management, weather integration
**Tech Stack:** Python 3.8+, Django 4.2+, PostgreSQL, Django Templates
**Key Libraries:** Django REST Framework, Requests, Pillow
Always organize imports in this exact order:
1. Standard library imports
2. Django imports
3. Third-party app imports
4. Local app imports
```python
import datetime
import uuid
from django.db import models
from django.shortcuts import render
import requests
from PIL import Image
from trips.models import Trip
from weather.services import get_weather
```
Apply these naming patterns consistently:
Follow these architectural patterns:
1. **Django MTV Pattern:** Model-Template-View architecture
2. **Class-Based Views:** Use for complex functionality
3. **Form Classes:** Create for all data input and validation
4. **Service Pattern:** Implement for external API calls (weather)
5. **OOP Principles:**
- Encapsulation: Keep data and methods together
- Single Responsibility: One class = one responsibility
- Composition over inheritance: Prefer composing objects
Use descriptive prefixes:
Follow conventional commit format:
```
feat: Add trip creation form
fix: Handle weather API errors
docs: Update README with setup instructions
style: Format code according to PEP 8
refactor: Simplify weather data caching
test: Add tests for trip model validation
chore: Update dependencies
```
Before submitting:
```bash
python manage.py test
```
Create a `.env` file with:
```
DATABASE_URL=postgresql://username:password@localhost:5432/travelapp
SECRET_KEY=your_secret_key
WEATHER_API_KEY=your_weather_api_key
```
```bash
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
```
Always implement proper error handling for external operations:
```python
def get_weather(location):
try:
response = requests.get(f"{API_URL}?location={location}&key={API_KEY}")
response.raise_for_status()
return response.json()
except requests.RequestException as e:
logger.error(f"Weather API error: {e}")
return None
```
Before submitting code, verify:
1. Run `python manage.py check` and `python manage.py test`
2. Ensure code follows PEP 8 and Django style
3. Verify naming conventions are followed
4. Confirm code follows MTV pattern and OOP principles
5. Check proper error handling is implemented
6. Verify tests cover key functionality
7. Ensure docstrings document all classes/functions
Follow these core principles:
When working on this project:
1. **Read project documentation first:** Check `FUNCTIONAL.md` for feature requirements and `ARCHITECTURE.md` for technical implementation details
2. **Follow naming conventions strictly:** Use the exact patterns specified above
3. **Organize imports properly:** Always follow the four-section import order
4. **Write tests first:** Create tests following the naming convention before implementing features
5. **Handle errors gracefully:** Implement try-except blocks for all external operations
6. **Review before committing:** Run through the checklist before submitting code
7. **Use conventional commits:** Format all commit messages according to the pattern
8. **Reference code tags:** Use the bracketed tags (e.g., `[CL-STYLE]`) when discussing specific guidelines
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/django-travel-app-development-guide/raw