djangocms_page_tags.utils

Warning

While functions in this module can be used in code to work with the tags, they are by no means to be considered as a stable API, so they may change in future release.

djangocms_page_tags.utils.get_cache_key(request, page, lang, site_id, title)[source]

Create the cache key for the current page and tag type

djangocms_page_tags.utils.get_page_tags(page)[source]

Retrieves all the tags for a Page instance.

Parameters:page – a Page instance
Returns:list or queryset of attached tags
Type:List
djangocms_page_tags.utils.get_page_tags_from_request(request, page_lookup, lang, site, title=False)[source]

Get the list of tags attached to a Page or a Title from a request from usual page_lookup parameters.

Parameters:
  • request – request object
  • page_lookup – a valid page_lookup argument
  • lang – a language code
  • site – a site id
  • title – a boolean to extract the Page (if False) or Title instance
Returns:

list of tags

Type:

List

djangocms_page_tags.utils.get_title_tags(page, lang)[source]

Retrieves all the tags for a Title (given as page and language). This function does not use fallbacks to retrieve title object.

Parameters:
  • page – a Page instance
  • lang – a language code
Returns:

list or queryset of attached tags

Type:

List

djangocms_page_tags.utils.get_title_tags_from_request(request, page_lookup, lang, site)[source]

Get the list of tags attached to a Title from a request from usual page_lookup parameters.

Parameters:
  • request – request object
  • page_lookup – a valid page_lookup argument
  • lang – a language code
  • site – a site id
Returns:

list of tags attached to the given Title

Type:

List

djangocms_page_tags.utils.page_has_tag(page, tag)[source]

Check if a Page object is associated with the given tag.

Parameters:
  • page – a Page instance
  • tag – a Tag instance or a slug string.
Returns:

whether the Page instance has the given tag attached (False if no Page or no attached PageTags exists)

Type:

Boolean

djangocms_page_tags.utils.title_has_tag(page, lang, tag)[source]

Check if a Title object is associated with the given tag. This function does not use fallbacks to retrieve title object.

Parameters:
  • page – a Page instance
  • lang – a language code
  • tag – a Tag instance or a slug string.
Returns:

whether the Title instance has the given tag attached (False if no Title or no attached TitleTags exists)

Type:

Boolean