Overview
Tags provide a way to:- Configure program-specific behavior without code changes
- Enable/disable features per program
- Store configuration values accessible throughout the codebase
- Provide admin-editable settings through the tag settings page
esp/esp/tagdict/models.py with tag definitions in esp/esp/tagdict/__init__.py.
Tag Types
Global Tags
Apply to the entire site, independent of any program:Program Tags
Apply to specific programs, with fallback to global values:Using Tags
Reading Tag Values
Setting Tag Values
Unsetting Tags
Creating New Tags
1. Define the Tag
Add toesp/esp/tagdict/__init__.py:
2. Tag Definition Format
3. Tag Categories
Available categories defined intag_categories:
- teach: Teacher registration and class management
- learn: Student registration and learning features
- manage: Administrative and program management
- onsite: On-site check-in and operations
- volunteer: Volunteer management
- theme: Site theming and appearance
4. Custom Form Fields
Specify validation with custom fields:Tag Model
TheTag model uses Django’s generic foreign key system:
Query Examples
Common Tag Examples
Boolean Tags
Numeric Tags
String Tags
JSON Tags
Caching
Tag retrieval is cached using the@cache_function decorator:
Best Practices
Don't Access Tags at Import Time
Don't Access Tags at Import Time
Validate Tag Data
Validate Tag Data
Implement validation since admins can set invalid values:
Use Appropriate Tag Types
Use Appropriate Tag Types
- Use
getBooleanTag()for boolean values - Use
getTag()for strings and numbers - Use
getProgramTag()when you want program-specific values with global fallback
Provide Clear Help Text
Provide Clear Help Text
Help text is shown to admins in the settings interface:
Choose Sensible Defaults
Choose Sensible Defaults
Default values should represent the most common configuration:
Admin Interface
Tags with'is_setting': True appear on the tag settings page at /manage/[program]/settings/tags/.
Admins can:
- View all available tags with help text
- Edit tag values through form fields
- See current values vs. defaults
- Set program-specific overrides
Troubleshooting
Common Issues
Related
- Tag definitions:
esp/esp/tagdict/__init__.py - Tag model:
esp/esp/tagdict/models.py - Admin interface:
/manage/[program]/settings/tags/