Skip to main content

django-ogp-view

ViewクラスにOGP (The Open Graph protocol)を適応させるライブラリです。
本ライブラリのViewMixinを継承させることで、ogp metaタグの実装が簡略化できます。
画面ごとにカスタマイズすることもできます。
SEO (Search Engine Optimization)対策に最適です。

導入

  1. ライブラリをインストールする。
    pip install django-ogp-view
     or
    pip install git+https://github.com/taogya/DjangoOgpView.git
    
  2. settings.pyに以下を追加する。
    INSTALLED_APPS = [
        :
        'django_ogp'
    ]
    OGP_SITE_PROPERTY_MODEL = 'django_ogp.OgpSiteProperty'
    OGP_LOCALE_MASTER_MODEL = 'django_ogp.OgpLocaleMaster'
    OGP_MIMETYPE_MASTER_MODEL = 'django_ogp.OgpMimeTypeMaster'
    
  3. migrateを行う。
    python manage.py makemigrations
    python manage.py migrate
    
  4. OGP用のプロパティを設定する。
    • OgpSiteProperty
      サイト内共通のプロパティ。
    • OgpBasicProperty
      ページごとのプロパティ。
    • OgpCustomProperty
      カスタムプロパティ。
      JSONで指定する。
      JSONについて, keyはpropertyの名称, valueはcontentの値で指定する。
  5. ViewにOgpViewMixinを継承し, 割り当てるプロパティのレコードを割り当てる。
    from django.views import View
    from django_ogp.view import OgpViewMixin
    from django_ogp.models import OgpBasicProperty
    
    class YourView(View, OgpViewMixin):
        ogp = OgpBasicProperty.objects.first()
        :
    
  6. 以下のようにhtmlファイルにdjango_ogp用のタグを追加する。
    {% load django_ogp %}
    <!DOCTYPE html>
    <html lang="en" prefix="{{ view.ogp_global_prefix }}">
    <head prefix="{{ view.ogp_prefix }}">
        {% add_ogp_meta %}
        :
    

Models

django_ogp_er_

補足

  • マイグレーションファイル にはマスターデータ自動生成スクリプトが含まれています。
    不要なデータがありましたら, 管理者画面にて削除するかマイグレーションファイルを修正してください。
  • 以下のモデルはswappableなモデルです。
    • OgpSiteProperty
    • OgpLocaleMaster
    • OgpMimeTypeMaster

Metadata

Release files for django-ogp-view 1.1.0

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-ogp-view 1.1.0
File Size Uploaded Provenance Actions
django_ogp_view-1.1.0.tar.gz 15.0 kB Without provenance Details for django_ogp_view-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-ogp-view 1.1.0
File Interpreter ABI Platform Actions
django_ogp_view-1.1.0-py3-none-any.whl Python 3 none any Details for django_ogp_view-1.1.0-py3-none-any.whl

Total release size: 35.1 kB

Release files / django_ogp_view-1.1.0.tar.gz

Download URL django_ogp_view-1.1.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b740bc62497134fa81b289f97285ac445a00229d807865327f3810126a48f024
BLAKE2b-256 checksum
How to use checksums
8ae13e4f7b84f4df0ae5ad863ad6af1cb4124465c5bdd49254c7d6f307df0993
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / django_ogp_view-1.1.0-py3-none-any.whl

Download URL django_ogp_view-1.1.0-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
617c4dc688feafdb4775be52a719761025123dc62fc4cab5d709ac56cd2a3622
BLAKE2b-256 checksum
How to use checksums
9133875c5c5924e3d6e291578a9bcd19ee21312c0bcd7b3afafe9bfa14a40c57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for django-ogp-view 1.1.0

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.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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