TicketQuery Wiki Macro

The TicketQuery macro lets you display ticket information anywhere that accepts WikiFormatting. The query language used by the [[TicketQuery]] macro is described in the TracQuery page.

Usage

[[TicketQuery]]

Wiki macro listing tickets that match certain criteria.

This macro accepts a comma-separated list of keyed parameters, in the form "key=value".

If the key is the name of a field, the value must use the syntax of a filter specifier as defined in TracQuery#QueryLanguage. Note that this is not the same as the simplified URL syntax used for query: links starting with a ? character. Commas (,) can be included in field values by escaping them with a backslash (\).

Groups of field constraints to be OR-ed together can be separated by a literal or argument.

In addition to filters, several other named parameters can be used to control how the results are presented. All of them are optional.

The format parameter determines how the list of tickets is presented:

  • list -- the default presentation is to list the ticket ID next to the summary, with each ticket on a separate line.
  • compact -- the tickets are presented as a comma-separated list of ticket IDs.
  • count -- only the count of matching tickets is displayed
  • rawcount -- only the count of matching tickets is displayed, not even with a link to the corresponding query (since 1.1.1)
  • table -- a view similar to the custom query view (but without the controls)
  • progress -- a view similar to the milestone progress bars

The max parameter can be used to limit the number of tickets shown (defaults to 0, i.e. no maximum).

The order parameter sets the field used for ordering tickets (defaults to id).

The desc parameter indicates whether the order of the tickets should be reversed (defaults to false).

The group parameter sets the field used for grouping tickets (defaults to not being set).

The groupdesc parameter indicates whether the natural display order of the groups should be reversed (defaults to false).

The verbose parameter can be set to a true value in order to get the description for the listed tickets. For table format only. deprecated in favor of the rows parameter

The rows parameter can be used to specify which field(s) should be viewed as a row, e.g. rows=description|summary

The col parameter can be used to specify which fields should be viewed as columns. For table format only.

For compatibility with Trac 0.10, if there's a last positional parameter given to the macro, it will be used to specify the format. Also, using "&" as a field separator still works (except for order) but is deprecated.

Examples

Example Result Macro
Number of Triage tickets: 618 [[TicketQuery(status=new&milestone=,count)]]
Number of new tickets: 618 [[TicketQuery(status=new,count)]]
Number of reopened tickets: 0 [[TicketQuery(status=reopened,count)]]
Number of assigned tickets: 454 [[TicketQuery(status=assigned,count)]]
Number of invalid tickets: 5258 [[TicketQuery(status=closed,resolution=invalid,count)]]
Number of worksforme tickets: 1080 [[TicketQuery(status=closed,resolution=worksforme,count)]]
Number of duplicate tickets: 4379 [[TicketQuery(status=closed,resolution=duplicate,count)]]
Number of wontfix tickets: 4212 [[TicketQuery(status=closed,resolution=wontfix,count)]]
Number of fixed tickets: 18885 [[TicketQuery(status=closed,resolution=fixed,count)]]
Number of untriaged tickets (milestone unset): 1072 [[TicketQuery(status!=closed,milestone=,count)]]
Total number of tickets: 35874 [[TicketQuery(count)]]
Number of tickets reported or owned by current user: 1488 [[TicketQuery(reporter=$USER,or,owner=$USER,count)]]
Number of tickets created this month: 26 [[TicketQuery(created=thismonth..,count)]]
Number of closed Firefox tickets: 8 [[TicketQuery(status=closed,keywords~=firefox,count)]]
Number of closed Opera tickets: 25 [[TicketQuery(status=closed,keywords~=opera,count)]]
Number of closed tickets affecting Firefox and Opera: 0 [[TicketQuery(status=closed,keywords~=firefox opera,count)]]
Number of closed tickets affecting Firefox or Opera: 33 [[TicketQuery(status=closed,keywords~=firefox|opera,count)]]
Number of tickets that affect Firefox or are closed and affect Opera: 33 [[TicketQuery(status=closed,keywords~=opera,or,keywords~=firefox,count)]]
Number of closed Firefox tickets that don't affect Opera: 0 [[TicketQuery(status=closed,keywords~=firefox -opera,count)]]
Last 3 modified tickets: #36329, #35095, #36659 [[TicketQuery(max=3,order=modified,desc=1,compact)]]

Details of ticket #1:

[[TicketQuery(id=1,col=id|owner|reporter,rows=summary,table)]]

Ticket Owner Reporter
#1 Jacob Adrian Holovaty
Summary Create architecture for anonymous sessions

Format: list

[[TicketQuery(version=0.6|0.7&resolution=duplicate)]]

This is displayed as:

No results

[[TicketQuery(id=123)]]

This is displayed as:

#123
Typo in the model_api/#field-types

Format: compact

[[TicketQuery(version=0.6|0.7&resolution=duplicate, compact)]]

This is displayed as:

No results

Format: count

[[TicketQuery(version=0.6|0.7&resolution=duplicate, count)]]

This is displayed as:

0

Format: progress

[[TicketQuery(milestone=0.12.8&group=type,format=progress)]]

This is displayed as:

Uncategorized

2024 / 2026

Bug

10383 / 10758

New feature

3803 / 4189

Cleanup/optimization

5377 / 5685

Format: table

You can choose the columns displayed in the table format (format=table) using col=<field>. You can specify multiple fields and the order they are displayed in by placing pipes (|) between the columns:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter)]]

This is displayed as:

Full rows

In table format you can specify full rows using rows=<field>:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter,rows=description)]]

This is displayed as:

Results (1 - 3 of 34802)

1 2 3 4 5 6 7 8 9 10 11
Ticket Resolution Summary Owner Reporter
#36655 duplicate GZipMiddleware buffers streaming responses Adam Johnson Adam Johnson
Description

Currently, GZipMiddleware, via compress_sequence(), buffers the entire response before sending it to the client. This can cause issues for clients that expect to receive data in chunks, such as those using Server-Sent Events (SSE) or WebSockets.

This issue was reported to me in the django-browser-reload project back in Issue #161 (2023), where a contributor fixed it with a workaround, and I didn't think to investigate. Now, while implementing django-http-compression, I have realized that it’s a proper bug that can be fixed by adding a call to zfile.flush(), as done in its PR #8.

To reproduce the issue, use the app below, which can be run with uv run --script. If you comment out GzipMiddleware and load the page in a browser, you will see the numbers incrementing every second. If you include GzipMiddleware, the page will never load. Adding the zfile.flush() call in compress_sequence() fixes the issue.

#!/usr/bin/env uv run --script
# /// script
# requires-python = ">=3.14"
# dependencies = [
#     "django",
# ]
# ///
from __future__ import annotations

import os
import sys
import time

from django.conf import settings
from django.core.wsgi import get_wsgi_application
from django.http import StreamingHttpResponse
from django.urls import path

settings.configure(
    # Dangerous: disable host header validation
    ALLOWED_HOSTS=["*"],
    # Use DEBUG=1 to enable debug mode
    DEBUG=(os.environ.get("DEBUG", "") == "1"),
    # Make this module the urlconf
    ROOT_URLCONF=__name__,
    # Only gzip middleware
    MIDDLEWARE=[
        "django.middleware.gzip.GZipMiddleware",
    ],
)


def clock(request):
    def stream():
        yield "<h1>Clock</h1>\n"
        count = 1
        while True:
            yield f"<p>{count}</p>\n"
            count += 1
            time.sleep(1)

    return StreamingHttpResponse(stream())


urlpatterns = [
    path("", clock),
]

app = get_wsgi_application()

if __name__ == "__main__":
    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
#36651 invalid Brute-force password attack against inactive users returns distinct error message heindrickdumdum0217
Description

https://github.com/django/django/blob/main/django/contrib/auth/backends.py#L71

    def authenticate(self, request, username=None, password=None, **kwargs):
        if username is None:
            username = kwargs.get(UserModel.USERNAME_FIELD)
        if username is None or password is None:
            return
        try:
            user = UserModel._default_manager.get_by_natural_key(username)
        except UserModel.DoesNotExist:
            # Run the default password hasher once to reduce the timing
            # difference between an existing and a nonexistent user (#20760).
            UserModel().set_password(password)
        else:
            if user.check_password(password) and self.user_can_authenticate(user):
                return user

We have implemented user account lock after 3 consecutive failed login attempts. When user try to login in 4-th item we have to show correct error message about user account is locked, but for now it's impossible without rewriting "authenticate" function again.

But the current code checks password first, then check user can authenticate. It means if user receives different error message, user can sure at least username and password are correct. It may allow hackers can try with different password as many as times until they receive different error message.

For example, when password is not match, it returns error message unable to login with provided credentials. But when acount is locked, it returns error message "your account is locked".

This is just an example. What I'm going to say is we should check if user can authenticate first after get user from username or email. Then compare password, otherwise it may allow hackers guess password.

Of course I can inherit ModelBackend class and update "authenticate" function, but I don't think it's a good approach. When we inhert, we should use at least super class's function not override, because the "authenticate" function can be updated later in next Django releases.

#36650 duplicate oracledb-3.4.0 -> TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union MV
Description

When upgrading oracledb to version 3.4.0, Django stops working with error "TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union."

Using oracledb-3.3.0 works as expected.

Performing system checks...

System check identified no issues (0 silenced).
2025-10-08 09:18:33,020: INFO: acst_app.models.file: 10001 
2025-10-08 09:18:33,023: INFO: acst_app.models.file: 10001 elapsed time 00m00s
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.13.7/lib/python3.13/threading.py", line 1043, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/root/.pyenv/versions/3.13.7/lib/python3.13/threading.py", line 994, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
    ~~^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/core/management/commands/runserver.py", line 137, in inner_run
    self.check_migrations()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/core/management/base.py", line 587, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
                  ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/migrations/loader.py", line 58, in __init__
    self.build_graph()
    ~~~~~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/migrations/loader.py", line 235, in build_graph
    self.applied_migrations = recorder.applied_migrations()
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/migrations/recorder.py", line 89, in applied_migrations
    if self.has_table():
       ~~~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/migrations/recorder.py", line 63, in has_table
    with self.connection.cursor() as cursor:
         ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/base/base.py", line 320, in cursor
    return self._cursor()
           ~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/base/base.py", line 296, in _cursor
    self.ensure_connection()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/base/base.py", line 279, in ensure_connection
    self.connect()
    ~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/base/base.py", line 258, in connect
    self.init_connection_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/oracle/base.py", line 336, in init_connection_state
    cursor.execute(
    ~~~~~~~~~~~~~~^
        "SELECT 1 FROM DUAL WHERE DUMMY %s"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        % self._standard_operators["contains"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ["X"],
        ^^^^^^
    )
    ^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/oracle/base.py", line 630, in execute
    query, params = self._fix_for_params(query, params, unify_by_values=True)
                    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/oracle/base.py", line 627, in _fix_for_params
    return query, self._format_params(params)
                  ~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/oracle/base.py", line 555, in _format_params
    return {k: OracleParam(v, self, True) for k, v in params.items()}
               ~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/django_acst_venv_3137/lib/python3.13/site-packages/django/db/backends/oracle/base.py", line 441, in __init__
    elif isinstance(param, (Database.Binary, datetime.timedelta)):
         ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union
1 2 3 4 5 6 7 8 9 10 11


See also: TracQuery, TracTickets, TracReports

Last modified 21 months ago Last modified on Jan 24, 2024, 9:58:09 AM
Note: See TracWiki for help on using the wiki.
Back to Top