wiki:TracQuery
Last modified 4 years ago Last modified on 06/12/10 12:12:07

Trac Ticket Queries

In addition to reports, Trac provides support for custom ticket queries, used to display lists of tickets meeting a specified set of criteria.

To configure and execute a custom query, switch to the View Tickets module from the navigation bar, and select the Custom Query link.

Filters

When you first go to the query page the default filter will display tickets relevant to you:

  • If logged in then all open tickets it will display open tickets assigned to you.
  • If not logged in but you have specified a name or email address in the preferences then it will display all open tickets where your email (or name if email not defined) is in the CC list.
  • If not logged and no name/email defined in the preferences then all open issues are displayed.

Current filters can be removed by clicking the button to the right with the minus sign on the label. New filters are added from the pulldown lists at the bottom corners of the filters box ('And' conditions on the left, 'Or' conditions on the right). Filters with either a text box or a pulldown menu of options can be added multiple times to perform an or of the criteria.

You can use the fields just below the filters box to group the results based on a field, or display the full description for each ticket.

Once you've edited your filters click the Update button to refresh your results.

Clicking on one of the query results will take you to that ticket. You can navigate through the results by clicking the Next Ticket or Previous Ticket links just below the main menu bar, or click the Back to Query link to return to the query page.

You can safely edit any of the tickets and continue to navigate through the results using the Next/Previous/Back to Query links after saving your results. When you return to the query any tickets which were edited will be displayed with italicized text. If one of the tickets was edited such that it no longer matches the query criteria the text will also be greyed. Lastly, if a new ticket matching the query criteria has been created, it will be shown in bold.

The query results can be refreshed and cleared of these status indicators by clicking the Update button again.

Saving Queries

Trac allows you to save the query as a named query accessible from the reports module. To save a query ensure that you have Updated the view and then click the Save query button displayed beneath the results. You can also save references to queries in Wiki content, as described below.

Note: one way to easily build queries like the ones below, you can build and test the queries in the Custom report module and when ready - click Save query. This will build the query string for you. All you need to do is remove the extra line breaks.

You may want to save some queries so that you can come back to them later. You can do this by making a link to the query from any Wiki page.

[query:status=new|assigned|reopened&version=1.0 Active tickets against 1.0]

Which is displayed as:

Active tickets against 1.0

This uses a very simple query language to specify the criteria (see Query Language).

Alternatively, you can copy the query string of a query and paste that into the Wiki link, including the leading ? character:

[query:?status=new&status=assigned&status=reopened&group=owner Assigned tickets by owner]

Which is displayed as:

Assigned tickets by owner

Using the [[TicketQuery]] Macro

The TicketQuery macro lets you display lists of tickets matching certain criteria anywhere you can use WikiFormatting.

Example:

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

This is displayed as:

#258
post_syncdb is not sent to handlers registered in migrated apps
#263
[mysql] Incorrect SQL issued for TimeField with default value
#405
Permissions set through class Meta are not picked up
#409
south breaks manage.py test
#423
Custom ForeignKey Field with hardcoded proxy model fails
#438
Oracle migrate error
#443
__import__
#450
Backwards data migrations do not obey no_dry_run
#455
Wrong columns order when use migrate for table creation
#708
Flase is False and not 0

Just like the query: wiki links, the parameter of this macro expects a query string formatted according to the rules of the simple ticket query language.

A more compact representation without the ticket summaries is also available:

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

This is displayed as:

#258, #263, #405, #409, #423, #438, #443, #450, #455, #708

Finally if you wish to receive only the number of defects that match the query using the count parameter.

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

This is displayed as:

10

Customizing the table format

You can also customize the columns displayed in the table format (format=table) by using col=<field> - you can specify multiple fields and what order they are displayed by placing pipes (|) between the columns like below:

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

This is displayed as:

Results (1 - 3 of 710)

1 2 3 4 5 6 7 8 9 10 11
Ticket Resolution Summary Owner Reporter
#1377 invalid Tables not created in MySql using Wamp server (Mezzanine/South) andrew anonymous
#1371 fixed Front page link to Django broken andrew anonymous
#1360 wontfix Load fixtures from migrations with south orm schema. andrew proofit404@…
1 2 3 4 5 6 7 8 9 10 11

Full rows

In table format you can also have full rows by using rows=<field> like below:

[[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 710)

1 2 3 4 5 6 7 8 9 10 11
Ticket Resolution Summary Owner Reporter
#1377 invalid Tables not created in MySql using Wamp server (Mezzanine/South) andrew anonymous

Reported by anonymous, 2 weeks ago.

Description

I have created Models like

models.py file: from django.db import models from mezzanine.pages.models import Page

class Author(Page):

dob = models.DateField?("Date of birth")

and installed south by writing command easy_install South and then write python manage.py createdb, python manage.py syncdb and python mange.py migrate commands these shows that tables have created but when no tables created in database.

Here is my settings.py file

from future import absolute_import, unicode_literals

###################### # MEZZANINE SETTINGS # ######################

# The following settings are already defined with default values in # the defaults.py module within each of Mezzanine's apps, but are # common enough to be put here, commented out, for convenient # overriding. Please consult the settings documentation for a full list # of settings Mezzanine implements: # http://mezzanine.jupo.org/docs/configuration.html#default-settings

# Controls the ordering and grouping of the admin menu. # # ADMIN_MENU_ORDER = ( # ("Content", ("pages.Page", "blog.BlogPost?", # "generic.ThreadedComment?", ("Media Library", "fb_browse"),)), # ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")), # ("Users", ("auth.User", "auth.Group",)), # )

# A three item sequence, each containing a sequence of template tags # used to render the admin dashboard. # # DASHBOARD_TAGS = ( # ("blog_tags.quick_blog", "mezzanine_tags.app_list"), # ("comment_tags.recent_comments",), # ("mezzanine_tags.recent_actions",), # )

# A sequence of templates used by the page_menu template tag. Each # item in the sequence is a three item sequence, containing a unique ID # for the template, a label for the template, and the template path. # These templates are then available for selection when editing which # menus a page should appear in. Note that if a menu template is used # that doesn't appear in this setting, all pages will appear in it.

# PAGE_MENU_TEMPLATES = ( # (1, "Top navigation bar", "pages/menus/dropdown.html"), # (2, "Left-hand tree", "pages/menus/tree.html"), # (3, "Footer", "pages/menus/footer.html"), # )

# A sequence of fields that will be injected into Mezzanine's (or any # library's) models. Each item in the sequence is a four item sequence. # The first two items are the dotted path to the model and its field # name to be added, and the dotted path to the field class to use for # the field. The third and fourth items are a sequence of positional # args and a dictionary of keyword args, to use when creating the # field instance. When specifying the field class, the path # django.models.db. can be omitted for regular Django model fields. # # EXTRA_MODEL_FIELDS = ( # ( # # Dotted path to field. # "mezzanine.blog.models.BlogPost?.image", # # Dotted path to field class. # "somelib.fields.ImageField?", # # Positional args for field class. # ("Image",), # # Keyword args for field class. # {"blank": True, "upload_to": "blog"}, # ), # # Example of adding a field to *all* of Mezzanine's content types: # ( # "mezzanine.pages.models.Page.another_field", # "IntegerField?", # 'django.db.models.' is implied if path is omitted. # ("Another name",), # {"blank": True, "default": 1}, # ), # )

# Setting to turn on featured images for blog posts. Defaults to False. # # BLOG_USE_FEATURED_IMAGE = True

# If True, the south application will be automatically added to the # INSTALLED_APPS setting. USE_SOUTH = True

######################## # MAIN DJANGO SETTINGS # ########################

# People who get code error notifications. # In the format (('Full Name', 'email@…'), # ('Full Name', 'anotheremail@…')) ADMINS = (

# ('Your Name', 'your_email@…'),

) MANAGERS = ADMINS

# Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts

ALLOWED_HOSTS = ['example.com' ]

# Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # On Unix systems, a value of None will cause Django to use the same # timezone as the operating system. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = "America/Vancouver?" # If you set this to True, Django will use timezone-aware datetimes. USE_TZ = True

# Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = "en"

# Supported languages _ = lambda s: s LANGUAGES = (

('en', _('English')),

)

# A boolean that turns on/off debug mode. When set to True, stack traces # are displayed for error pages. Should always be set to False in # production. Best set to True in local_settings.py DEBUG = False

# Whether a user's session cookie expires when the Web browser is closed. SESSION_EXPIRE_AT_BROWSER_CLOSE = True

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = False

# Tuple of IP addresses, as strings, that: # * See debug comments, when DEBUG is true # * Receive x-headers INTERNAL_IPS = ("127.0.0.1",)

# List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = (

"django.template.loaders.filesystem.Loader", "django.template.loaders.app_directories.Loader",

)

AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend?",)

# List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = (

"django.contrib.staticfiles.finders.FileSystemFinder?", "django.contrib.staticfiles.finders.AppDirectoriesFinder?",

# 'django.contrib.staticfiles.finders.DefaultStorageFinder?', )

# The numeric mode to set newly-uploaded files to. The value should be # a mode you'd pass directly to os.chmod. FILE_UPLOAD_PERMISSIONS = 0o644

############# # DATABASES # #############

DATABASES = {

"default": {

# Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle". "ENGINE": "django.db.backends.mysql", # DB name or path to database file if using sqlite3. "NAME": "abc", # Not used with sqlite3. "USER": "root", # Not used with sqlite3. "PASSWORD": "123", # Set to empty string for localhost. Not used with sqlite3. "HOST": "", # Set to empty string for default. Not used with sqlite3. "PORT": "",

}

}

######### # PATHS # #########

import os

# Full filesystem path to the project. PROJECT_ROOT = os.path.dirname(os.path.abspath(file))

# Name of the directory for the project. PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1]

# Every cache key will get prefixed with this value - here we set it to # the name of the directory the project is in to try and use something # project specific. CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_DIRNAME

# URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = "/static/"

# Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))

# URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = STATIC_URL + "media/"

# Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))

# Package/module name to import the root urlpatterns from for the project. ROOT_URLCONF = "%s.urls" % PROJECT_DIRNAME

# Put strings here, like "/home/html/django_templates" # or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),)

################ # APPLICATIONS # ################ #AUTH_PROFILE_MODULE = "project_name.MyProfile?" ACCOUNTS_VERIFICATION_REQUIRED = True INSTALLED_APPS = (

"django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.redirects", "django.contrib.sessions", "django.contrib.sites", "django.contrib.sitemaps", "django.contrib.staticfiles", "mezzanine.boot", "mezzanine.conf", "mezzanine.core", "mezzanine.generic", "mezzanine.blog", "mezzanine.forms", "mezzanine.pages", "mezzanine.galleries", "mezzanine.twitter", "mezzanine.accounts", "project_name", "south" #"mezzanine.mobile",

)

# List of processors used by RequestContext? to populate the context. # Each one should be a callable that takes the request object as its # only parameter and returns a dictionary to add to the context. TEMPLATE_CONTEXT_PROCESSORS = (

"django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.static", "django.core.context_processors.media", "django.core.context_processors.request", "django.core.context_processors.tz", "mezzanine.conf.context_processors.settings", #"mezzanine.pages.page_processors.processor_for",

)

# List of middleware classes to use. Order is important; in the request phase, # these middleware classes will be applied in the order given, and in the # response phase the middleware will be applied in reverse order. MIDDLEWARE_CLASSES = (

"mezzanine.core.middleware.UpdateCacheMiddleware?", "django.contrib.sessions.middleware.SessionMiddleware?", "django.middleware.locale.LocaleMiddleware?", "django.contrib.auth.middleware.AuthenticationMiddleware?", "django.middleware.common.CommonMiddleware?", "django.middleware.csrf.CsrfViewMiddleware?", "django.contrib.messages.middleware.MessageMiddleware?", "mezzanine.core.request.CurrentRequestMiddleware?", "mezzanine.core.middleware.RedirectFallbackMiddleware?", "mezzanine.core.middleware.TemplateForDeviceMiddleware?", "mezzanine.core.middleware.TemplateForHostMiddleware?", "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware?", "mezzanine.core.middleware.SitePermissionMiddleware?", # Uncomment the following if using any of the SSL settings: # "mezzanine.core.middleware.SSLRedirectMiddleware", "mezzanine.pages.middleware.PageMiddleware?", "mezzanine.core.middleware.FetchFromCacheMiddleware?", 'django.contrib.messages.middleware.MessageMiddleware?', 'django.middleware.clickjacking.XFrameOptionsMiddleware',

)

# Store these package names here as they may change in the future since # at the moment we are using custom forks of them. PACKAGE_NAME_FILEBROWSER = "filebrowser_safe" PACKAGE_NAME_GRAPPELLI = "grappelli_safe"

######################### # OPTIONAL APPLICATIONS # #########################

# These will be added to INSTALLED_APPS, only if available. OPTIONAL_APPS = (

"debug_toolbar", "django_extensions", "compressor", PACKAGE_NAME_FILEBROWSER, PACKAGE_NAME_GRAPPELLI,

)

DEBUG_TOOLBAR_CONFIG = {"INTERCEPT_REDIRECTS": False}

################### # DEPLOY SETTINGS # ###################

# These settings are used by the default fabfile.py provided. # Check fabfile.py for defaults.

# FABRIC = { # "SSH_USER": "", # SSH username for host deploying to # "HOSTS": ALLOWED_HOSTS[:1], # List of hosts to deploy to (eg, first host) # "DOMAINS": ALLOWED_HOSTS, # Domains for public site # "REPO_URL": "ssh://hg@bitbucket.org/user/project", # Project's repo URL # "VIRTUALENV_HOME": "", # Absolute remote path for virtualenvs # "PROJECT_NAME": "", # Unique identifier for project # "REQUIREMENTS_PATH": "requirements.txt", # Project's pip requirements # "GUNICORN_PORT": 8000, # Port gunicorn will listen on # "LOCALE": "en_US.UTF-8", # Should end with ".UTF-8" # "DB_PASS": "", # Live database password # "ADMIN_PASS": "", # Live admin user password # "SECRET_KEY": SECRET_KEY, # "NEVERCACHE_KEY": NEVERCACHE_KEY, # }

################## # LOCAL SETTINGS # ##################

# Allow any settings to be defined in local_settings.py which should be # ignored in your version control system allowing for settings to be # defined per machine. try:

from local_settings import *

except ImportError?:

pass

#################### # DYNAMIC SETTINGS # ####################

# set_dynamic_settings() will rewrite globals based on what has been # defined so far, in order to provide some better defaults where # applicable. We also allow this settings module to be imported # without Mezzanine installed, as the case may be when using the # fabfile, where setting the dynamic settings below isn't strictly # required. try:

from mezzanine.utils.conf import set_dynamic_settings

except ImportError?:

pass

else:

set_dynamic_settings(globals())

My project name is mpj .

I am using Wamp to save database/tables. My database name is abcdef There are no tables in my database but still after running migration commands it shows my warnings/errors. Django is working fine with my Wamp server, then why mezzanine is showing me errors that "Your database doesn't support running schema-altering statements"

Note: I have mention "south" in my Installed Apps.

Error: No table named mpj_authors . You are using database that doesn't support schema migration. You can manually change this.

How to solve this problem

#1371 fixed Front page link to Django broken andrew anonymous

Reported by anonymous, 3 weeks ago.

Description

When I click on the "Django" link on the front page, it takes me to http://djangoproject.org/ which does not work. It should be http://djangoproject.com/ instead because they've apparently switched TLDs. Thanks.

#1360 wontfix Load fixtures from migrations with south orm schema. andrew proofit404@…

Reported by proofit404@…, 4 weeks ago.

Description

For loading fixtures in migrations I need to call django management command directly in migration. But I can change this model in future migrations i.e. add field to it. After that fixture migration will fail because old fixtures doesn't match new schema. Because of loaddata command has deal with models in source code, not in south orm schema.

The only way for work around this is read fixtures in migration and looping throw it and create necessary models with south orm.

After that there is nice to have one general way in south api for loading fixtures in migrations.

P.S. I can try to implement this if you consider to add this functionality to South.

1 2 3 4 5 6 7 8 9 10 11

Query Language

query: TracLinks and the [[TicketQuery]] macro both use a mini “query language” for specifying query filters. Basically, the filters are separated by ampersands (&). Each filter then consists of the ticket field name, an operator, and one or more values. More than one value are separated by a pipe (|), meaning that the filter matches any of the values. To include a litteral & or | in a value, escape the character with a backslash (\).

The available operators are:

= the field content exactly matches the one of the values
~= the field content contains one or more of the values
^= the field content starts with one of the values
$= the field content ends with one of the values

All of these operators can also be negated:

!= the field content matches none of the values
!~= the field content does not contain any of the values
!^= the field content does not start with any of the values
!$= the field content does not end with any of the values

The date fields created and modified can be constrained by using the = operator and specifying a value containing two dates separated by two dots (..). Either end of the date range can be left empty, meaning that the corresponding end of the range is open. The date parser understands a few natural date specifications like "3 weeks ago", "last month" and "now", as well as Bugzilla-style date specifications like "1d", "2w", "3m" or "4y" for 1 day, 2 weeks, 3 months and 4 years, respectively. Spaces in date specifications can be left out to avoid having to quote the query string.

created=2007-01-01..2008-01-01 query tickets created in 2007
created=lastmonth..thismonth query tickets created during the previous month
modified=1weekago.. query tickets that have been modified in the last week
modified=..30daysago query tickets that have been inactive for the last 30 days

See also: TracTickets, TracReports, TracGuide