Skip to main content

django-simple-metatags

https://secure.travis-ci.org/whitespy/django-simple-metatags.svg https://badge.fury.io/py/django-simple-metatags.svg https://codecov.io/gh/whitespy/django-simple-metatags/branch/master/graph/badge.svg https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336

The django application allows to add title, keywords and description meta tags to site’s pages.

Features

  • Attaching meta tags to model instances

  • Attaching meta tags to URL paths

  • Caching

  • Integration with the django-modeltranslation application

Installation

pip install django-simple-metatags

Configuration

  1. Add ‘metatags’ to your INSTALLED_APPS:

INSTALLED_APPS = (
    # ...
    'metatags',
)
  1. Run the migrate management command:

python manage.py migrate metatags
  1. Customize model admin classes:

To be able to attach meta tags to a model instance you should slightly adjust a model admin class.

The first way by adding the MetaTagInline class in inlines sequence:

from metatags.admin import MetaTagInline


class CustomModelAdmin(admin.ModelAdmin):
    # ...
    inlines = (MetaTagInline,)

The second way by using MetaTagAbleMixin:

from metatags.admin import MetaTagAbleMixin


class CustomModelAdmin(MetaTagAbleMixin, admin.ModelAdmin):
    # ...

The third and way by using MetaTagAbleModelAdmin:

from metatags.admin import MetaTagAbleModelAdmin


class CustomModelAdmin(MetaTagAbleModelAdmin):
    # ...
  1. Load the metatags template library and add the include_metatags template tag in template.

Add the include_metatags template tag with the model_instance argument to use meta tags attached to a model instance.

{% load metatags %}
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    {% include_metatags object default_title='Foo' default_keywords='Foo, bar, baz' %}
</head>

Add the include_metatags without the model_instance argument to use meta tags attached to an URL path.

{% load metatags %}
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    {% include_metatags default_title='Foo' default_keywords='Foo, bar, baz' %}
</head>

Arguments of include_metatags template tag

All arguments are optional.

model_instance - A model instance with attached meta tags. Defaults to None.

default_title - A default title of page. Defaults to ‘’.

default_keywords - Default keywords of page. Defaults to ‘’.

default_description - Default description of page. Defaults to ‘’.

Caching

Since version 2.0.0 application gained caching support. See settings section for more details.

Settings

METATAGS_CACHE_ENABLED - Enables meta tags caching to minimize database access. Defaults to False.

METATAGS_CACHE_ALIAS - A name of cache backend used by meta tags caching feature. Defaults to default.

METATAGS_CACHE_TIMEOUT - Timeout in seconds to use for meta tags caching. If value set up to None cached meta tags never expire. Defaults to None.

Management command

resetmetatagscache - Removes all cached meta tags.

Metadata

Release files for django-simple-metatags 2.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-simple-metatags 2.0.3
File Size Uploaded Provenance Actions
django-simple-metatags-2.0.3.tar.gz 13.1 kB Without provenance Details for django-simple-metatags-2.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-simple-metatags 2.0.3
File Interpreter ABI Platform Actions
django_simple_metatags-2.0.3-py3-none-any.whl Python 3 none any Details for django_simple_metatags-2.0.3-py3-none-any.whl

Total release size: 33.9 kB

Release files / django-simple-metatags-2.0.3.tar.gz

Download URL django-simple-metatags-2.0.3.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5adc5916a4cb8d8341adf0d58721163b232c43a480b143be6ed3a8aa69e98b7a
BLAKE2b-256 checksum
How to use checksums
b43dc15be07edfa2973e7f2eb652a0307751a8c324b18e4169587a9924bd8b5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

Release files / django_simple_metatags-2.0.3-py3-none-any.whl

Download URL django_simple_metatags-2.0.3-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa3af16627a975d260412daf118290957f77bcb33763c698b69d939a4d3c2b50
BLAKE2b-256 checksum
How to use checksums
dc2f91e61e493ce2433c08fc409db6502dd8ed279950082f8a420a82da7e1ff2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

Security for django-simple-metatags 2.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page