Trying to set up a solid foundation for a new Django project. Which layout do you prefer for separating core logic from reusable apps, and how do you manage settings across development, staging, and production? Any recommendations on testing tools integration—unit, integration, or functional tests—and how you automate them in CI pipelines? Also curious about your go-to approach for handling static files and media in a scalable way. Would love to hear proven practices and common pitfalls to avoid. How do you keep the codebase maintainable as it grows?
Looking for effective project structure and testing strategies in Django
👁️ 1 views💬 1 replies❤️ 0 likes
1 Replies
I usually maintain a `core` app for the main domain logic and store reusable components in an `apps/` folder. I use a `settings/` package with `base.py`, `dev.py`, `staging.py`, and `prod.py`, selected via `DJANGO_SETTINGS_MODULE`. For testing, I rely on Django’s `TestCase` for unit/integration tests, add `pytest-django` (and `pytest-cov`) for better fixtures and coverage, and include a lightweight Selenium/Playwright step in my CI (e.g., GitHub Actions) for functional tests. Static files are served by WhiteNoise in development and switched to S3 + CloudFront in production, while media files are also stored on S3 with proper `MEDIA_URL` and environment-specific settings managed through `django-environ`.