Admin and Views
Why do I get 'ImproperlyConfigured' error after attaching an extra view to admin class?
Why do I get 'ImproperlyConfigured' error after attaching an extra view to admin class?
AttachmentsMixin, a separate AttachmentsView class is created.See ralph/attachments/admin.py for implementation examples.How do I see asset boxes in front dashboard?
How do I see asset boxes in front dashboard?
- Asset must be in ‘in progress’ or ‘in use’ state
- Asset must be assigned to the current user
- Transition IDs must be configured in settings
-
Create the database and superuser:
-
Create a transition:
- Navigate to:
http://localhost:8000/transitions/transitionmodel/1/ - Click [add another transition]
- Set:
- Source: ‘in progress’
- Destination: ‘in use’
- Click [Save]
- Navigate to:
-
Find the transition ID:
Note the
idvalue (e.g.,1) -
Configure settings:
Add to
settings/dev.py:Replace1with your actual transition ID. -
Create test assets:
Navigate to
http://localhost:8000/back_office/backofficeasset/add/and create assets with:- Status: ‘in progress’
- Assigned to user: r2
- Owner: r2 Repeat with statuses ‘return in progress’ and ‘loan in progress’.
-
View dashboard:
Open incognito mode and login as user
r2to see the dashboard boxes.
Why do I get 'NoReverseMatch' error for transition_bulk?
Why do I get 'NoReverseMatch' error for transition_bulk?
API Development
How do I create a new API endpoint?
How do I create a new API endpoint?
/api/my-models/.See API Documentation for advanced features.How do I optimize API queries to avoid N+1 problems?
How do I optimize API queries to avoid N+1 problems?
select_related and prefetch_related in your ViewSet:django.db.connection.queries to identify N+1 queries.How do I add custom filtering to an API endpoint?
How do I add custom filtering to an API endpoint?
/api/my-models/?name=test&status=active2. Lookup filtering (automatic):
Usage: /api/my-models/?name__startswith=test&created_date__gte=2024-01-013. Extended filters for polymorphic models:/api/my-models/?name=test searches all specified fields4. Custom filter backend:How do I implement separate serializers for read and write operations?
How do I implement separate serializers for read and write operations?
save_serializer_class attribute:- GET requests return nested objects
- POST/PUT/PATCH requests accept IDs
Models and Database
How do I add custom validation to a model?
How do I add custom validation to a model?
clean() method:- In Django admin forms
- In API requests (if using
RalphAPISerializer) - When calling
full_clean()orsave()with validation
How do I create database migrations?
How do I create database migrations?
- Review generated migrations before committing
- Add data migrations for complex changes
- Test migrations on a copy of production data
- Never modify applied migrations
How do I use custom fields?
How do I use custom fields?
-
Enable custom fields in admin:
- Custom fields are automatically available in API
-
Access in code:
Testing
How do I run tests?
How do I run tests?
How do I write API tests?
How do I write API tests?
How do I use factories for test data?
How do I use factories for test data?
Deployment and Configuration
How do I configure Ralph settings?
How do I configure Ralph settings?
settings/base.py- Base settingssettings/dev.py- Development overridessettings/prod.py- Production overridessettings/test.py- Test overrides
settings/local.py:How do I enable debug mode safely?
How do I enable debug mode safely?
- Use logging instead of DEBUG=True
- Configure Sentry or similar error tracking
- Use Django’s logging framework
How do I set up logging?
How do I set up logging?
Performance and Optimization
How do I profile slow queries?
How do I profile slow queries?
/silk/ for profiling UI.How do I optimize large querysets?
How do I optimize large querysets?
Need More Help?
If your question isn’t answered here:- Check the Development Guide
- Review API Documentation
- Search GitHub Issues
- Ask in Ralph community channels