If you need additional fields for warmup queries follow these simple steps:
- Add the new field to
class Backend
, similar to the already existing fields:class Backend(models.Model): # ... myField = models.TextField( default="", blank=True, verbose_name="My field", help_text="My field description", )
- Add the new field to function
getWarmupAndAcPlaceholders
. This defines the name of the template variable. In this case, the template variable would therefore be called%MY_FIELD%
def getWarmupAndAcPlaceholders(self): data = { # ... "MY_FIELD": self.myField, } return data
- (Optional) Add the field to
class BackendDefaults
if you want to be able to provide a default value for it.class BackendDefaults(Backend): AVAILABLE_DEFAULTS = ( # ... 'myField' )
- Add your field to
BackendAdmin.fieldsets
. This will make the field available in the Django admin. Your field will most likely fit into the'Warmup Query Patterns'
or'Warmup Queries'
sections.fieldsets = ( # ... # Do not add your field to both sections. You need to decide on one of these! ('Warmup Query Patterns', { 'fields': ('...', 'myField'), 'description': '...' }), ('Warmup Queries', { 'fields': ('...', 'myField'), 'description': '...' }), # ... )
- If your field is a warmup query that needs to be pinned in the QLever cache, add it to the
pin
functiondef pin(self): prefixString = self._getPrefixString() warmups = ( # ... (self.backend.myField, "Describe what this query does. This will be displayed in the log"), )
And that's all. Your new field is ready to use.