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.

Files for checklist-seo, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size checklist_seo-0.0.7-py3-none-any.whl (35.5 kB) File type Wheel Python version py3 Upload date Hashes View

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page