Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
django-simple-metatags
The django application allows to add title, keywords and description meta tags to site's pages.
Readme
.. image:: https://secure.travis-ci.org/whitespy/django-simple-metatags.svg :target: http://travis-ci.org/whitespy/django-simple-metatags
.. image:: https://badge.fury.io/py/django-simple-metatags.svg :target: https://badge.fury.io/py/django-simple-metatags
.. image:: https://codecov.io/gh/whitespy/django-simple-metatags/branch/master/graph/badge.svg :target: https://codecov.io/gh/whitespy/django-simple-metatags
.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336 :target: https://pycqa.github.io/isort/
|
The django application allows to add title, keywords and description meta tags to site's pages.
.. code:: bash
pip install django-simple-metatags
.. code:: python
INSTALLED_APPS = (
# ...
'metatags',
)
2. Run the migrate management command:
.. code:: bash
python manage.py migrate metatags
3. 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:
.. code:: python
from metatags.admin import MetaTagInline
class CustomModelAdmin(admin.ModelAdmin):
# ...
inlines = (MetaTagInline,)
The second way by using MetaTagAbleMixin:
.. code:: python
from metatags.admin import MetaTagAbleMixin
class CustomModelAdmin(MetaTagAbleMixin, admin.ModelAdmin):
# ...
The third and way by using MetaTagAbleModelAdmin:
.. code:: python
from metatags.admin import MetaTagAbleModelAdmin
class CustomModelAdmin(MetaTagAbleModelAdmin):
# ...
.. warning::
Meta tags can be attached only to models that has auto-incrementing or positive integer primary key.
.. note::
Also django-simple-metatags application has an own model admin class that allows to attach meta tags to URL
paths.
4. 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.
.. code:: html
{% 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>
.. note::
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.
.. code:: html
{% 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>
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.
.. note::
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.
.. note::
Value of **0** causes meta tags to immediately expire.
resetmetatagscache - Removes all cached meta tags.
FAQs
The django application allows to add title, keywords and description meta tags to site's pages.
We found that django-simple-metatags demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.