Files
pack/examples/python-django/mysite/urls.py
T
868fcdabc4 test: add hiredis python test (#349)
* feat: add Redis with Hiredis support to python-django example

Add Redis caching alongside existing PostgreSQL database connection to
demonstrate multi-service integration. Configure Django to use Redis
cache backend with Hiredis parser for improved performance.

Changes:
- Add Redis service to docker-compose.yml
- Add redis and hiredis dependencies to pyproject.toml
- Configure Redis cache in Django settings with HiredisParser
- Create home view demonstrating both Redis cache and direct connection
- Update test.json to include REDIS_URL environment variable

* chore: update Python bytecode cache for django example

* chore: remove Python cache files and update gitignore

Remove __pycache__ files that were incorrectly committed and add Python-specific patterns to .gitignore to prevent future commits of cache files.

Changes:
- Remove all __pycache__/*.pyc files from git tracking
- Add Python cache patterns to .gitignore (__pycache__/, *.pyc, *.pyo, etc.)
- Update CLAUDE.md to explicitly document that cache files should never be committed

The .gitignore was missing Python patterns because it was generated from a Go template and never updated for Python examples.

* docs: clarify guidance on build artifacts in gitignore

* chore: update uv.lock for python-django with redis dependencies

* fix: remove incorrect HiredisParser configuration

Redis-py automatically uses hiredis when it's installed - no explicit
parser_class configuration is needed. The incorrect configuration was
causing ImportError since HiredisParser is not exposed as a public API.

Hiredis will be automatically detected and used by redis-py for
improved performance when the hiredis package is available.

---------

Co-authored-by: Hanzo Dev <[email protected]>
2025-11-18 16:46:50 -07:00

25 lines
821 B
Python

"""
URL configuration for mysite project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name='home'),
path('admin/', admin.site.urls),
]