IDE Setup Guide - Using Docker Container Packages¶
This guide helps you configure your IDE to use the Python packages installed in the Docker container, eliminating import warnings and providing proper Django development support.
🚨 The Problem¶
You're seeing import warnings like:
This happens because your IDE doesn't know about:
1. The Django environment setup in the Docker container
2. The correct Python path (src/ directory)
3. Django's settings module
4. The UV-managed packages in /home/python/.local/
✅ Solutions Implemented¶
1. VS Code Remote Container (.devcontainer/devcontainer.json)¶
- ✅ Full Docker container development environment
- ✅ Pre-configured with all necessary extensions
- ✅ Automatic Python path configuration
- ✅ Port forwarding for Django (8000) and Flower (5555)
2. VS Code Configuration (.vscode/settings.json)¶
- ✅ Added Docker container Python paths
- ✅ Configured Django-aware type checking
- ✅ Set up proper Python interpreter path
- ✅ Enabled auto-import completions
- ✅ Added Docker terminal integration
3. Pyright Configuration (pyrightconfig.json)¶
- ✅ Configured Python path and version (3.14)
- ✅ Set up execution environment for Docker container
- ✅ Enabled workspace-wide type checking
- ✅ Added Docker container site-packages path
4. Project Configuration (pyproject.toml)¶
- ✅ Added Pyright and MyPy tool configurations
- ✅ Set Python version and paths
- ✅ Configured type checking mode
5. Docker IDE Setup Script (scripts/setup-docker-ide.sh)¶
- ✅ Automated IDE configuration
- ✅ Creates VS Code workspace file
- ✅ Generates PyCharm configuration
- ✅ Tests Django imports in container
🔧 How to Apply the Fix¶
Option 1: Automated Setup (Recommended)¶
Run the setup script to automatically configure your IDE:
This will: - Check Docker is running - Build containers if needed - Extract Python paths from container - Create VS Code workspace file - Generate PyCharm configuration - Test Django imports
Option 2: VS Code Remote Container (Best Experience)¶
- Install Remote Containers extension
- Open command palette:
Cmd+Shift+P - Select: "Remote-Containers: Reopen in Container"
- Wait for container to build and start
- Enjoy full Docker development environment!
Option 3: Manual VS Code Configuration¶
- Open VS Code workspace:
code laboratory-system.code-workspace - Select Python interpreter:
Cmd+Shift+P→ "Python: Select Interpreter" - Choose Docker container Python:
/home/python/.local/bin/python - Restart language server:
Cmd+Shift+P→ "Python: Restart Language Server"
For Other IDEs:¶
PyCharm:¶
- Run setup script:
./scripts/setup-docker-ide.sh - Open project in PyCharm
- Configure interpreter:
File→Settings→Project→Python Interpreter - Add remote interpreter: Docker → Use Docker Compose
- Select service:
web - Set interpreter path:
/home/python/.local/bin/python
Cursor:¶
- Use VS Code settings (compatible)
- Or use Remote Container approach
- Restart Cursor after configuration
Vim/Neovim with LSP:¶
Add to your LSP config:
-- For nvim-lspconfig
require('lspconfig').pyright.setup({
settings = {
python = {
analysis = {
extraPaths = {
"./src",
"/home/python/.local/lib/python3.14/site-packages"
},
typeCheckingMode = "basic"
}
}
}
})
🧪 Testing the Fix¶
After applying the configuration:
- Open any Django file (e.g.,
src/accounts/views.py) - Check the Problems panel - import warnings should be gone
- Try auto-completion - Django imports should work
- Hover over Django classes - you should see type information
🐳 Docker Development¶
Since this project runs in Docker, the IDE configuration is designed to work with: - Local development: IDE resolves imports for better editing experience - Docker execution: Actual code runs in the container with proper Django setup
📁 File Structure¶
laboratory-system/
├── .vscode/
│ └── settings.json # VS Code configuration
├── pyrightconfig.json # Pyright type checker config
├── pyproject.toml # Project config with tool settings
├── setup-dev.py # Development setup script
└── src/ # Django project root
├── config/
├── accounts/
├── protocols/
└── pages/
🔍 Troubleshooting¶
If warnings persist:¶
-
Check Python interpreter:
-
Verify Django installation:
-
Restart language server:
- VS Code:
Cmd+Shift+P→ "Python: Restart Language Server" -
Cursor: Similar command
-
Clear cache:
For Docker-only development:¶
If you only develop inside Docker and don't have Django installed locally:
-
Install Django locally (for IDE support):
-
Or use remote development:
- VS Code Remote Containers extension
- Develop directly inside the Docker container
📚 Additional Resources¶
✅ Verification¶
After setup, you should see: - ✅ No import warnings in Problems panel - ✅ Django auto-completion working - ✅ Type hints for Django classes - ✅ Proper syntax highlighting - ✅ Go-to-definition working for Django imports
Note: These configurations are designed to work with the existing Docker-based development workflow while providing better IDE support for local editing.