Skip to main content

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

Project description

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


  • Attaching meta tags to model instances
  • Attaching meta tags to URL paths
  • Caching
  • Integration with the django-modeltranslation application


pip install django-simple-metatags


  1. Add ‘metatags’ to your INSTALLED_APPS:
    # ...
  1. Run the migrate management command:
python 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):
    # ...


Meta tags can be attached only to models that has auto-incrementing or positive integer primary key.


Also django-simple-metatags application has an own model admin class that allows to attach meta tags to URL paths.

  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 %}
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    {% include_metatags object default_title='Foo' default_keywords='Foo, bar, baz' %}


The model_instance attribute is just an instance of arbitrary model like User, FlatPage, etc. with attached via Django’s admin meta tags. A variable than contains a model instance must be included in the template context.

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

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

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 ‘’.


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


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


Django’s caching system must be configured.

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.


Value of 0 causes meta tags to immediately expire.

Management command

resetmetatagscache - Removes all cached meta tags.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-simple-metatags-2.0.3.tar.gz (13.1 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page