The full checklist to provide tools inside Django in order to write right content
Project description
Check list SEO
Features
- Keyword repartition
- Length content
- Check title article length
- Url is optimized
- Number internal Links
Installation
Pypi
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">'Keep current slug'</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">"Keep current slug or save to generate a new slug."</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">"""Redefinition of wagtail's _get_autogenerated_slug so you can use your own slug generator."""</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">'intro'</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">'date'</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">'delay'</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">"Blog information"</span><span class="p">),</span> <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">'intro'</span><span class="p">),</span> <span class="n">StreamFieldPanel</span><span class="p">(</span><span class="s1">'body'</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">'images_keyword'</span><span class="p">),</span> <span class="p">],</span> <span class="n">heading</span><span class="o">=</span><span class="s2">"Images"</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">"selected_image"</span><span class="p">,</span> <span class="n">heading</span><span class="o">=</span><span class="s2">"Image sélectionnée"</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">'slug'</span><span class="p">),</span> <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">'keep_slug'</span><span class="p">),</span> <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">'seo_title'</span><span class="p">),</span> <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">'show_in_menus'</span><span class="p">),</span> <span class="n">FieldPanel</span><span class="p">(</span><span class="s1">'search_description'</span><span class="p">),</span> <span class="p">],</span> <span class="n">heading</span><span class="o">=</span><span class="s2">"Common Page Configuration"</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">'Content'</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">"Promote"</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">'Settings'</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 includeurlpatterns = [ ... 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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27c930bba2571c5651424d1303e72f6bd3e337be5c30b8c3cd9c5ccb5663bcbb |
|
MD5 | 84cb08e66771769b95cc85952adb0b14 |
|
BLAKE2b-256 | 495393a0f493f62fb6c53fd0255612617578af73f99dd87226e7b1277b77a2f0 |