{ "info": { "author": "Oleg Kleschunov", "author_email": "igorkleschunov@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "============================\ndjango-ok-seo |PyPI version|\n============================\n\n|Build Status| |Code Health| |Coverage| |Requirements Status| |Python Versions| |PyPI downloads| |license|\n|Project Status|\n\nThis app allows you to add meta tags and OpenGraph properties to your HTML responses.\n\nInstallation\n============\n\nInstall with pip:\n\n.. code:: shell\n\n $ pip install django-ok-seo\n\nUpdate INSTALLED_APPS:\n\n.. code:: python\n\n INSTALLED_APPS = [\n ...\n 'seo',\n 'modeltranslation', # optional\n 'django_jinja', # optional for jinja2 global function\n ...\n ]\n\nMake migrations\n\n.. code:: shell\n\n $ python manage.py migrate\n\n\nIf you want to make ``seo models`` translatable, you need to install `django-modeltranslation`_ package. After that run:\n\n.. code:: shell\n\n $ python manage.py makemigrations\n $ python manage.py migrate\n\nto create new fields in `seo models` for each language.\n\n\nFeatures\n========\n\nThere are two options of usage:\n\n1) ``UrlSeo`` - a model to fetch seo data by an url.\n\n2) ``ViewSeo`` and ``ModelInstanceSeo`` - models to attach seo data for specific views (using choices) and objects (using \u201cgeneric\u201d relationships). \n\n\nAvailable settings\n==================\n\n``SEO_USE_URL_SEO`` - Flag to use (display in an admin interface) only `UrlSeo` model. `False` by default.\n\n``SEO_USE_URL_FULL_PATH`` - Flag to use a whole path, plus an appended query string, to search `UrlSeo` isntances. `False` by default.\n\n``SEO_VIEWS_CHOICES`` - Tuple of tuples for using with `ViewSeo`. The first value is the value to use in s code and a second is a verbose (translated) value.\n\nFor example:\n\n.. code:: python\n\n SEO_VIEWS_CHOICES = (\n ('index', 'Index'),\n ('faq', 'Faq'),\n )\n\n\n``SEO_MODELS`` - List of models names to limit content type choices for 'ModelInstanceSeo'.\n\nFor example (use lowercase):\n\n.. code:: python\n\n SEO_MODELS = [\n 'article.article',\n 'auth.user'\n ]\n\n\n``SEO_DEFAULT_IMAGE`` - Path to default image, which will be used for 'og:image' property.\n\n``SEO_IMAGE_WIDTH`` - Value of `width` for image. `1200` by default.\n\n``SEO_IMAGE_HEIGHT`` - Value of `height` for image. `630` by default.\n\n``SEO_IMAGE_EXTENSIONS`` - List of allowed image extensions for ImageField in seo model. \n\n``SEO_IMAGE_STORAGE`` - Custom file storage for ImageField in seo model. '`django.core.files.storage.FileSystemStorage`' by default.\n\n``SEO_OBJECT_IMAGE_FIELD`` - A name of field to get image from an object. '`image`' by default.\n\nBy default:\n\n.. code:: python\n \n ['jpg', 'jpeg', 'png']\n\n\n``SEO_OG_TYPES`` - Tuple of tuples of open graph object types.\n\nBy default:\n\n.. code:: python\n\n DEFAULT_OBJECT_TYPES = (\n ('website', pgettext_lazy('OG types', 'Website')),\n ('article', pgettext_lazy('OG types', 'Article'))\n )\n\n\n``SEO_TWITTER_TYPES`` - Tuple of tuples of twitter card types.\n\nBy default:\n\n.. code:: python\n\n DEFAULT_TWITTER_TYPES = (\n ('summary', pgettext_lazy('Twitter card types', 'Summary Card')),\n ('summary_large_image', pgettext_lazy('Twitter card types', 'Summary Card with Large Image')),\n ('player', pgettext_lazy('Twitter card types', 'Player')),\n ('app', pgettext_lazy('Twitter card types', 'App')),\n )\n\n``SEO_FB_APP_ID`` - Common Facebook application id. Also, You can set custom id in facebook_app_id field for each seo instance.\n\n``SEO_HTML_ADMIN_WIDGET`` - Dictionary with default widget for `top_text` and `bottom_text` text fields in django admin interface.\n\n``SEO_DEBUG_MODE`` - Sets debug mode. If ``True`` adds `` to all pages.\n\n``SEO_URL_SEO_SITEMAP_PRIORITY`` - `UrlSeo` sitemap priority. `1` by default.\n\n``SEO_URL_SEO_SITEMAP_CHANGEFREQ`` - `UrlSeo` sitemap changefreq. `always` by default.\n\nFor example:\n\n.. code:: python\n\n SEO_HTML_ADMIN_WIDGET = {\n 'widget': 'TinyMCE',\n 'widget_path': 'tinymce.widgets'\n }\n\n\nBasic example to use:\n=====================\n\nAdmin inline (for `ModelInstanceSeo`):\n--------------------------------------\n\n.. code:: python\n\n # admin.py\n\n from django.contrib import admin\n\n from seo.admin import ModelInstanceSeoInline\n\n from apps.article.models import Article\n\n @admin.register(Article)\n class ArticleAdmin(admin.ModelAdmin):\n inlines = [ModelInstanceSeoInline]\n \n\nViews (examples for all models):\n--------------------------------\n\n.. code:: python\n\n # views.py\n\n from django.views.generic import DetailView, TemplateView\n\n from seo.mixins.views import (\n ViewSeoMixin, \n ModelInstanceViewSeoMixin, \n UrlSeoMixin\n )\n\n from apps.article.models import Article\n\n\n class IndexView(ViewSeoMixin, TemplateView):\n seo_view = 'index'\n template_name = 'index.html'\n\n\n class IndexViewJinja(ViewSeoMixin, TemplateView):\n seo_view = 'index'\n template_name = 'jinja/index.jinja'\n\n\n class ArticleDetailView(ModelInstanceViewSeoMixin, DetailView):\n template_name = 'article.html'\n model = Article\n pk_url_kwarg = 'id'\n\n\n class ArticleDetailViewJinja(ModelInstanceViewSeoMixin, DetailView):\n template_name = 'jinja/article.jinja'\n model = Article\n pk_url_kwarg = 'id'\n\n\n class IndexUrlSeoView(UrlSeoMixin, TemplateView):\n template_name = 'index.html'\n\n\n class ArticleUrlSeoDetailView(UrlSeoMixin, DetailView):\n template_name = 'article.html'\n model = Article\n pk_url_kwarg = 'id'\n\n\nContext processor (for `UrlSeo`):\n---------------------------------\n\n.. code:: python\n\n # ...\n 'seo.context_processors.seo',\n\n\nMiddleware (for `UrlSeo`) to use from `request` variable in tepmlates:\n----------------------------------------------------------------------\n\n.. code:: python\n\n MIDDLEWARE = [\n ...\n\n # seo\n 'seo.middleware.url_seo_middleware'\n ]\n\n\nIn templates:\n\n\n.. code:: html\n\n {% load seo %}\n
\n \n {% get_seo_data request.seo %}\n \n\n\nYour templates:\n===============\n\n\\*.html\n-------\n\n.. code:: html\n\n {% load seo %}\n \n \n {% get_seo_data seo %}\n \n\n \n ...\n