Skip to main content

The full checklist to provide tools inside Django in order to write right content

Project description

Check list SEO Build

Maintainability Test Coverage

Features

  • Keyword repartition
  • Length content
  • Check title article length
  • Url is optimized
  • Number internal Links

Installation

Pypi

PyPI version

pip install checklist-seo

Installing the application in Django

To use this application, you need first to add it to your config file.

In your config file (ex: settings.py):

# Application definition

INSTALLED_APPS = [ ... 'seo' ... ]

SEO Pannel

To setup the keyword for SEO, you need to add a special SEO Pannel that will appear in your page creation in wagtail admin.

The module contains a model in models/SeoPage, the model need to be used as a base for your page models.

Example of your model:

class HomePage(SeoPage):
    date = models.DateField("Post date")
    intro = models.CharField(max_length=250)
    delay = models.IntegerField(default=0, validators=[MaxValueValidator(99), MinValueValidator(0)])
    body = StreamField([
        ('text', RichTextBlock(blank=True, features=['h2', 'h3', 'h4', 'bold', 'italic', 'link',
                                                     'code', 'ol', 'ul', 'hr', 'document-link', 'image', 'embed', 'superscript', 'subscript', 'strikethrough', 'blockquote'])),
        ('rawHtml', RawHTMLBlock(blank=True)),
    ], blank=True)
    images_keyword = models.CharField(max_length=250, blank=True)
    selected_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
<span class="n">keep_slug</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">BooleanField</span><span class="p">(</span>
    <span class="n">verbose_name</span><span class="o">=</span><span class="p">(</span><span class="s1">&#39;Keep current slug&#39;</span><span class="p">),</span>
    <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
    <span class="n">help_text</span><span class="o">=</span><span class="p">(</span><span class="s2">&quot;Keep current slug or save to generate a new slug.&quot;</span><span class="p">)</span>
<span class="p">)</span>

<span class="k">def</span> <span class="nf">_get_autogenerated_slug</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">base_slug</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Redefinition of wagtail&#39;s _get_autogenerated_slug so you can use your own slug generator.&quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">slug</span>

<span class="n">search_fields</span> <span class="o">=</span> <span class="n">Page</span><span class="o">.</span><span class="n">search_fields</span> <span class="o">+</span> <span class="p">[</span>
    <span class="n">index</span><span class="o">.</span><span class="n">SearchField</span><span class="p">(</span><span class="s1">&#39;intro&#39;</span><span class="p">),</span>
<span class="p">]</span>

<span class="n">content_panels</span> <span class="o">=</span> <span class="n">Page</span><span class="o">.</span><span class="n">content_panels</span> <span class="o">+</span> <span class="p">[</span>
    <span class="n">MultiFieldPanel</span><span class="p">([</span>
        <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;date&#39;</span><span class="p">),</span>
        <span class="n">FieldRowPanel</span><span class="p">([</span>
            <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;delay&#39;</span><span class="p">),</span>
        <span class="p">]),</span>
    <span class="p">],</span> <span class="n">heading</span><span class="o">=</span><span class="s2">&quot;Blog information&quot;</span><span class="p">),</span>
    <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;intro&#39;</span><span class="p">),</span>
    <span class="n">StreamFieldPanel</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">),</span>
    <span class="n">FieldRowPanel</span><span class="p">([</span>
        <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;images_keyword&#39;</span><span class="p">),</span>
    <span class="p">],</span> <span class="n">heading</span><span class="o">=</span><span class="s2">&quot;Images&quot;</span><span class="p">),</span>
    <span class="n">ImageChooserPanel</span><span class="p">(</span><span class="n">field_name</span><span class="o">=</span><span class="s2">&quot;selected_image&quot;</span><span class="p">,</span> <span class="n">heading</span><span class="o">=</span><span class="s2">&quot;Image sélectionnée&quot;</span><span class="p">),</span>
<span class="p">]</span>

<span class="n">promote_panels</span> <span class="o">=</span> <span class="p">[</span>
    <span class="n">MultiFieldPanel</span><span class="p">([</span>
        <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;slug&#39;</span><span class="p">),</span>
        <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;keep_slug&#39;</span><span class="p">),</span>
        <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;seo_title&#39;</span><span class="p">),</span>
        <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;show_in_menus&#39;</span><span class="p">),</span>
        <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">&#39;search_description&#39;</span><span class="p">),</span>
    <span class="p">],</span> <span class="n">heading</span><span class="o">=</span><span class="s2">&quot;Common Page Configuration&quot;</span><span class="p">),</span>
<span class="p">]</span>

<span class="n">edit_handler</span> <span class="o">=</span> <span class="n">TabbedInterface</span><span class="p">([</span>
    <span class="n">ObjectList</span><span class="p">(</span><span class="n">content_panels</span><span class="p">,</span> <span class="n">heading</span><span class="o">=</span><span class="s1">&#39;Content&#39;</span><span class="p">),</span>
    <span class="n">ObjectList</span><span class="p">(</span><span class="n">promote_panels</span><span class="p">,</span> <span class="n">heading</span><span class="o">=</span><span class="s2">&quot;Promote&quot;</span><span class="p">),</span>
    <span class="n">SeoPage</span><span class="o">.</span><span class="n">seo_object_list</span><span class="p">,</span>
    <span class="n">ObjectList</span><span class="p">(</span><span class="n">Page</span><span class="o">.</span><span class="n">settings_panels</span><span class="p">,</span> <span class="n">heading</span><span class="o">=</span><span class="s1">&#39;Settings&#39;</span><span class="p">)</span>
<span class="p">])</span>

Routing

In your routing projet file urls.py

from django.conf.urls import url
from django.urls import include

urlpatterns = [ ... url(r'^seo/', include('seo.urls'), name='seo'), ]

Static

To get the CSS / JS / Image file from this app to your projet python manage.py collectstatic

DB Migration

Now you can detect the change python manage.py makemigrations

And apply it on DB python manage.py migration

Test

pytest

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

checklist_seo-0.0.7-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file checklist_seo-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: checklist_seo-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

File hashes

Hashes for checklist_seo-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 27c930bba2571c5651424d1303e72f6bd3e337be5c30b8c3cd9c5ccb5663bcbb
MD5 84cb08e66771769b95cc85952adb0b14
BLAKE2b-256 495393a0f493f62fb6c53fd0255612617578af73f99dd87226e7b1277b77a2f0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page