API Reference#

This reference provides detailed information about the modules and classes in the django-help app.

Models#

Models for django_help.

class django_help.models.ArticleUpload(*args, **kwargs)[source]#

Bases: Model

Stores uploaded files for articles.

Parameters:
  • id (BigAutoField) – ID

  • upload (FileField) – upload

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

property extension#

Return the extension of the upload.

property filename#

Return the filename of the upload.

id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>#
upload#

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
class django_help.models.DjangoHelpArticle(*args, **kwargs)[source]#

Bases: Model

Stores articles.

Parameters:
  • id (BigAutoField) – ID

  • title_en (CharField) – The title of this article.

  • title_es (CharField) – The title of this article.

  • title_fr (CharField) – The title of this article.

  • subtitle_en (CharField) – A subtitle for this article.

  • subtitle_es (CharField) – A subtitle for this article.

  • subtitle_fr (CharField) – A subtitle for this article.

  • slug (SlugField) – A web address friendly version of the title.

  • category_id (ForeignKey) – The category this article belongs to, if any.

  • article_content_en (MarkdownxField) – The content of this article. Markdown is supported.

  • article_content_es (MarkdownxField) – The content of this article. Markdown is supported.

  • article_content_fr (MarkdownxField) – The content of this article. Markdown is supported.

  • views (PositiveIntegerField) – The number of times this article has been viewed.

  • icon (CharField) – The icon and text color to use for this article.

  • public (BooleanField) – Check this box to make this article public.

  • highlighted (BooleanField) – Check this box to highlight this article on the index page.

  • intended_entity_type (CharField) – The type of entity this article applies to.

  • created (DateTimeField) – created

  • modified (DateTimeField) – modified

  • tags (TaggableManager) – A comma-separated list of tags.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

add_relevant_path(path)[source]#

Add the specified path to this article.

Parameters:

path (str) –

article_content#
article_content_en#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

article_content_es#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

article_content_fr#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

category#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

category_id#
clean()[source]#

Ensure the intended entity type matches the category’s intended entity type.

content_preview(length=100)[source]#

Return a preview of the content, truncated to the specified length.

created#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_intended_entity_type_display(*, field=<django.db.models.fields.CharField: intended_entity_type>)#
get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)#
get_next_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)#
get_previous_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=False, **kwargs)#
highlighted#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

icon#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

intended_entity_type#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.DjangoHelpArticleManagerFromDjangoHelpArticleQuerySet object>#
public#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

relevant_paths#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

slug#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

subtitle#
subtitle_en#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

subtitle_es#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

subtitle_fr#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

taggedarticles_set#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

tags = <taggit.managers._TaggableManager object>#
title#
title_en#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title_es#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title_fr#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

views#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class django_help.models.DjangoHelpArticleManager(*args, **kwargs)[source]#

Bases: Manager

Manager for DjangoHelpArticle.

get_queryset()[source]#

Return the queryset for this manager.

class django_help.models.DjangoHelpArticleQuerySet(model=None, query=None, using=None, hints=None)[source]#

Bases: QuerySet

QuerySet for DjangoHelpArticle.

get_for_category(category, multiple=False)[source]#

Return article(s) matching the specified category.

If single is True (default), return only the first article.

Parameters:

category (str) –

get_for_path(path, multiple=False)[source]#

Return article(s) matching the specified path.

If single is True (default), return only the first article.

Parameters:

path (str | HttpRequest) –

get_for_slug(slug, multiple=False)[source]#

Return article(s) matching the specified slug.

If single is True (default), return only the first article.

Parameters:

slug (str) –

get_for_tag(tag, multiple=False)[source]#

Return article(s) matching the specified tag.

If single is True (default), return only the first article.

Parameters:

tag (str) –

intended_for_any()[source]#

Return article intended for any entity.

private()[source]#

Return only article which is not public.

public()[source]#

Return only article which is public.

search(search_terms)[source]#

Search for article matching the specified query in the current language.

Parameters:

search_terms (List[str]) –

top_three_highlighted()[source]#

Return the top three most viewed articles which are highlighted.

Return the top three most viewed articles.

top_three_recent()[source]#

Return the top three most recent articles.

class django_help.models.DjangoHelpCategory(*args, **kwargs)[source]#

Bases: Model

Stores categories.

Parameters:
  • id (BigAutoField) – ID

  • title_en (CharField) – The title of this category.

  • title_es (CharField) – The title of this category.

  • title_fr (CharField) – The title of this category.

  • subtitle_en (CharField) – A subtitle for this category.

  • subtitle_es (CharField) – A subtitle for this category.

  • subtitle_fr (CharField) – A subtitle for this category.

  • slug (SlugField) – A web address friendly version of the title.

  • description_en (CharField) – A description of this category.

  • description_es (CharField) – A description of this category.

  • description_fr (CharField) – A description of this category.

  • icon (CharField) – The icon and text color to use for this category.

  • public (BooleanField) – Check this box to make this category public.

  • intended_entity_type (CharField) – The type of entity this category applies to.

  • created (DateTimeField) – created

  • modified (DateTimeField) – modified

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

add_article(article)[source]#

Add the specified article to this category.

property article_count#

Return the number of article in this category.

articles#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

created#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description#
description_en#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description_es#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description_fr#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_intended_entity_type_display(*, field=<django.db.models.fields.CharField: intended_entity_type>)#
get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)#
get_next_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)#
get_previous_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=False, **kwargs)#
icon#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

intended_entity_type#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.DjangoHelpCategoryManagerFromDjangoHelpCategoryQuerySet object>#
public#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

static remove_article(article)[source]#

Remove the specified article from its category.

property short_description#

Return a short description of this category.

slug#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

subtitle#
subtitle_en#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

subtitle_es#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

subtitle_fr#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title#
title_en#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title_es#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title_fr#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class django_help.models.DjangoHelpCategoryManager(*args, **kwargs)[source]#

Bases: Manager

Manager for DjangoHelpCategory.

get_queryset()[source]#

Return the queryset for this manager.

class django_help.models.DjangoHelpCategoryQuerySet(model=None, query=None, using=None, hints=None)[source]#

Bases: QuerySet

QuerySet for DjangoHelpCategory.

intended_for_any()[source]#

Return categories intended for any entity.

private()[source]#

Return only categories which are not public.

public()[source]#

Return only categories which are public.

class django_help.models.RelevantPath(*args, **kwargs)[source]#

Bases: Model

Stores a relevant path for an article.

A relevant path is a path that is relevant to the article. For example, if the article is about creating a new provider, then the relevant path might be /providers/create.

Wildcards are supported. For example, if the article is about creating a new provider, then the relevant path might be /providers/*.

Parameters:
  • id (BigAutoField) – ID

  • path (CharField) – The relevant path for this article. Wildcards are supported.

  • article_id (ForeignKey) – article

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

article#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

article_id#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property is_wildcard#

Return True if the path is a wildcard path.

objects = <django.db.models.manager.Manager object>#
path#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class django_help.models.Tag(*args, **kwargs)[source]#

Bases: TagBase, Model

Customized Taggit Tag model.

Parameters:
  • id (BigAutoField) – ID

  • name (CharField) – name

  • slug (SlugField) – slug

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

django_help_taggedarticles_items#

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

slug#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class django_help.models.TaggedArticles(*args, **kwargs)[source]#

Bases: ItemBase, Model

Stores tagged articles.

Parameters:
  • id (BigAutoField) – ID

  • content_object_id (ForeignKey) – content object

  • tag_id (ForeignKey) – tag

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

content_object#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

content_object_id#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

tag#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

tag_id#
django_help.models.get_only_filters()[source]#

Return the fields to select in a queryset.

Views#

Views for django_help.

django_help.views.category(request, category_slug)#

The category page for django_help.

Provides: - a list of categories - a list of articles in the current category

Parameters:
  • request (HttpRequest) –

  • category_slug (str) –

Return type:

TemplateResponse

django_help.views.get_articles(request, *, category=None, slug=None, tag=None)#

Fetches articles based on category, slug, or tag.

Parameters:
  • request (HttpRequest) –

  • category (str) –

  • slug (str) –

  • tag (str) –

Return type:

TemplateResponse

django_help.views.index(request)#

The main django_help page.

Provides: - a search box - an option for admins to create new articles - a list of popular articles - a list of highlighted articles, and - a list of recent articles.

Parameters:

request (HttpRequest) –

Return type:

TemplateResponse

django_help.views.view_article(request, article_slug)#

Uses htmx to load a specific article instance based on the slug.

Parameters:
  • request (HttpRequest) –

  • article_slug (str) –

Return type:

TemplateResponse

Forms#

Forms for django_help.

class django_help.forms.ArticleUploadForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]#

Bases: ModelForm

Form for uploading articles in admin.

class Meta[source]#

Bases: object

Meta class for ArticleUploadForm.

fields = ['upload']#
model#

alias of ArticleUpload

base_fields = {'upload': <django.forms.fields.FileField object>}#
declared_fields = {}#
property media#

Return all media required to render the widgets on this form.

class django_help.forms.DjangoHelpArticleForm(*args, **kwargs)[source]#

Bases: ModelForm

Form for creating and editing articles.

class Meta[source]#

Bases: object

Meta class for DjangoHelpArticleForm.

fields = ('title_en', 'title_es', 'title_fr', 'subtitle_en', 'subtitle_es', 'subtitle_fr', 'category', 'article_content_en', 'article_content_es', 'article_content_fr', 'icon', 'public', 'highlighted', 'intended_entity_type', 'tags')#
model#

alias of DjangoHelpArticle

widgets = {'article_content_en': <markdownx.widgets.MarkdownxWidget object>, 'article_content_es': <markdownx.widgets.MarkdownxWidget object>, 'article_content_fr': <markdownx.widgets.MarkdownxWidget object>}#
__init__(*args, **kwargs)[source]#
base_fields = {'article_content_en': <markdownx.fields.MarkdownxFormField object>, 'article_content_es': <markdownx.fields.MarkdownxFormField object>, 'article_content_fr': <markdownx.fields.MarkdownxFormField object>, 'category': <django.forms.models.ModelChoiceField object>, 'highlighted': <django.forms.fields.BooleanField object>, 'icon': <django.forms.fields.CharField object>, 'intended_entity_type': <django.forms.fields.TypedChoiceField object>, 'public': <django.forms.fields.BooleanField object>, 'subtitle_en': <django.forms.fields.CharField object>, 'subtitle_es': <django.forms.fields.CharField object>, 'subtitle_fr': <django.forms.fields.CharField object>, 'tags': <taggit.forms.TagField object>, 'title_en': <django.forms.fields.CharField object>, 'title_es': <django.forms.fields.CharField object>, 'title_fr': <django.forms.fields.CharField object>}#
declared_fields = {}#
formfield_callback(**kwargs)#
property media#

Return all media required to render the widgets on this form.

class django_help.forms.RelevantPathForm(*args, **kwargs)[source]#

Bases: ModelForm

Form for creating RelevantPath instances.

class Meta[source]#

Bases: object

Meta class for RelevantPathForm.

fields = ('path',)#
model#

alias of RelevantPath

__init__(*args, **kwargs)[source]#
base_fields = {'path': <django.forms.fields.CharField object>}#
declared_fields = {}#
property media#

Return all media required to render the widgets on this form.

Admin#

Admin configuration for django_help.

class django_help.admin.DjangoHelpArticleAdmin(model, admin_site)[source]#

Bases: TranslatedFieldAdmin, MarkdownxModelAdmin

Admin configuration for DjangoHelpArticle instances.

actions = [<function export_articles>]#
changelist_view(request, extra_context=None)[source]#

Add the upload button to the changelist view.

fieldsets = (('title', {'fields': ['title_en', 'title_es', 'title_fr']}), ('subtitle', {'fields': ['subtitle_en', 'subtitle_es', 'subtitle_fr']}), ('article_content', {'fields': ['article_content_en', 'article_content_es', 'article_content_fr']}), ('', {'fields': ['category', 'slug', 'icon', 'public', 'highlighted', 'intended_entity_type', 'tags']}))#
get_queryset(request)[source]#

Prefetch tags for the queryset.

get_urls()[source]#

Add the upload view to the admin.

inlines = [<class 'django_help.admin.RelevantPathInline'>]#
list_display = ('title_en', 'slug', 'subtitle_en', 'category', 'icon', 'public', 'highlighted', 'intended_entity_type', 'views', 'tag_list', 'created', 'modified')#
list_filter = ('public', 'category', 'intended_entity_type', 'highlighted')#
property media#
prepopulated_fields = {'slug': ('title_en',)}#
readonly_fields = ('created', 'modified')#
search_fields = ('title_en', 'title_es', 'title_fr', 'subtitle_en', 'subtitle_es', 'subtitle_fr', 'article_content_en', 'article_content_es', 'article_content_fr', 'slug', 'tags')#
tag_list(obj)[source]#

Return a comma-separated list of tags for the object.

class django_help.admin.DjangoHelpCategoryAdmin(model, admin_site)[source]#

Bases: TranslatedFieldAdmin, ModelAdmin

Admin configuration for DjangoHelpCategory instances.

fieldsets = (('title', {'fields': ['title_en', 'title_es', 'title_fr']}), ('subtitle', {'fields': ['subtitle_en', 'subtitle_es', 'subtitle_fr']}), ('description', {'fields': ['description_en', 'description_es', 'description_fr']}), ('', {'fields': ['slug', 'icon', 'intended_entity_type', 'public', 'created', 'modified']}))#
list_display = ('title_en', 'slug', 'subtitle_en', 'icon', 'intended_entity_type', 'public', 'created', 'modified')#
list_filter = ('public', 'intended_entity_type')#
property media#
prepopulated_fields = {'slug': ('title_en',)}#
readonly_fields = ('created', 'modified')#
search_fields = ('title_en', 'title_es', 'title_fr', 'subtitle_en', 'subtitle_es', 'subtitle_fr', 'description_en', 'description_es', 'description_fr', 'slug')#
class django_help.admin.RelevantPathInline(parent_model, admin_site)[source]#

Bases: TabularInline

Inline for RelevantPath instances.

extra = 0#
property media#
model#

alias of RelevantPath

class django_help.admin.TaggedArticlesAdmin(model, admin_site)[source]#

Bases: ModelAdmin

Admin configuration for TaggedArticles instances.

list_display = ('tag',)#
property media#
search_fields = ('tag',)#
django_help.admin.export_articles(modeladmin, request, queryset)[source]#

Action to export the selected articles to Markdown (.md) and/or ZIP.

Utils#

Exporting#

Utility functions for exporting DjangoHelpArticle instances to Markdown or ZIP.

django_help.utils.exporting.article_to_markdown(article)[source]#

Convert a DjangoHelpArticle instance to a Markdown string for each language.

Parameters:

article (DjangoHelpArticle) –

Return type:

str

django_help.utils.exporting.export_articles_to_markdown_or_zip(queryset)[source]#

Export the given queryset of DjangoHelpArticle instances to Markdown (.md) and/or ZIP (if multiple).

Parameters:

queryset (QuerySet) –

Return type:

HttpResponse

Importing#

Utility functions for importing articles from Markdown files or ZIP archives.

class django_help.utils.importing.ArticleManager[source]#

Bases: object

Class to manage the creation and updating of DjangoHelpArticle instances from metadata and Markdown content.

__init__()[source]#
extract_language_contents(content)[source]#

Extract and map content to languages based on headers in the markdown.

Parameters:

content (str) –

Return type:

Dict

handle_zip_file(zip_file)[source]#

Extract and process each Markdown file in a ZIP archive.

Parameters:

zip_file (str | SpooledTemporaryFile) –

Return type:

None

manage_categories(metadata, defaults)[source]#

Manage category creation or fetching.

Uses the primary language title to create or fetch the category, and then sets the category for the article.

Parameters:
  • metadata (Dict) –

  • defaults (Dict) –

Return type:

None

manage_relevant_paths(article, metadata)[source]#

Clear and update relevant paths.

Parameters:
Return type:

None

manage_tags(article, metadata)[source]#

Update article tags.

Parameters:
Return type:

None

process_markdown_metadata(markdown_content)[source]#

Parse markdown content and prepare metadata including language-specific content.

Parameters:

markdown_content (str) –

Return type:

Dict | None

process_md_file(markdown_file)[source]#

Process a markdown file and create or update a DjangoHelpArticle instance.

Parameters:

markdown_file (str | SpooledTemporaryFile) –

Return type:

bool

read_markdown_content(markdown_file)[source]#

Read markdown content from a file or file-like object.

Parameters:

markdown_file (str | SpooledTemporaryFile) –

Return type:

str

set_defaults(metadata)[source]#

Set default values from metadata.

Parameters:

metadata (Dict) –

Return type:

Dict

update_or_create_article(metadata)[source]#

Update or create a DjangoHelpArticle instance from metadata.

Parameters:

metadata (Dict) –

Return type:

tuple[Optional[django_help.models.DjangoHelpArticle], bool]

django_help.utils.importing.upload_articles(request)[source]#

Insert upload handler before processing uploaded files.

We must ensure here that uploaded files are handled as temporary files See: https://docs.djangoproject.com/en/5.1/topics/http/file-uploads/#modifying-upload-handlers-on-the-fly

Parameters:

request (HttpRequest) –

Queryset#

Queryset utilities for the Django Help app.

django_help.utils.queryset.annotate_with_values_fields(queryset, values_fields)[source]#

Annotates the queryset with the values fields.

For instance, if values_fields = [“title”], the queryset will be annotated with title=to_attribute(“title”),

ensuring the current language is used. e.g.: If the currentl language is ‘en’, the annotation will convert title_en to title.

Parameters:

values_fields (list[str]) –

django_help.utils.queryset.filter_articles(request, category, slug, tag)[source]#

Filters articles based on user permissions and provided parameters.

Note: This is a helper function for get_articles.

Parameters:
  • request (HttpRequest) –

  • category (str) –

  • slug (str) –

  • tag (str) –

Return type:

DjangoHelpArticleQuerySet

django_help.utils.queryset.filter_user_can_view(request, articles_or_categories)[source]#

Filters QuerySet to return only public articles or categories based on the user’s entity context.

Parameters:
Return type:

Union[DjangoHelpArticleQuerySet, DjangoHelpCategoryQuerySet]

Regex#

Regex utilities for Django.

django_help.utils.regex.get_path_regex(request_or_path)[source]#

Returns a regex pattern that matches the current path.

Parameters:

request_or_path (HttpRequest | str) –

Return type:

str

Validation#

Validation utilities for the Django Help app.

django_help.utils.validation.user_authorized_to_view(request, article)[source]#

Raises a 404 error if the user is not allowed to view the article.

Parameters:
Return type:

Optional[Http404]

Template Tags#

Defines custom template tags for django_help.

django_help.templatetags.django_help_tags.django_help_category(category, title=None)[source]#

Renders a django_help button with the given category.

django_help.templatetags.django_help_tags.django_help_current_path(title=None)[source]#

Renders a django_help button with the given current path.

django_help.templatetags.django_help_tags.django_help_slug(slug, title=None)[source]#

Renders a django_help button with the given slug.

django_help.templatetags.django_help_tags.django_help_tag(tag, title=None)[source]#

Renders a django_help button with the given tag.

django_help.templatetags.django_help_tags.load_dependencies()[source]#

Loads the dependencies for django_help.

django_help.templatetags.django_help_tags.markdown_format(text)[source]#

Formats the given text as markdown and processes internal links.

django_help.templatetags.django_help_tags.querystring(context, query_dict=None, **kwargs)[source]#

Add, remove, and change parameters of a QueryDict and return the result as a query string. If the query_dict argument is not provided, default to request.GET.

For example:

{% querystring foo=3 %}

To remove a key:

{% querystring foo=None %}

To use with pagination:

{% querystring page=page_obj.next_page_number %}

A custom QueryDict can also be used:

{% querystring my_query_dict foo=3 %}

App Settings#

Settings for the django_help app.

Use the DJANGO_HELP_CONFIG setting to configure the app. For example:

DJANGO_HELP_CONFIG = {
    "BASE_MANAGER": "myapp.models.MyManager",
    "BASE_QUERYSET": "myapp.models.MyQuerySet",
    "BASE_MODEL": "myapp.models.MyModel",
    "BASE_FOREIGN_KEY": "myapp.models.MyForeignKey",
    "EXTRA_LANGUAGES": {
        "es": {"blank": False},  # Spanish fields must be filled out.
        "fr": {"blank": True},  # French fields can be left blank.
    },
    "AUTHORIZE_USER_TO_VIEW_ARTICLE": "myapp.utils.authorize_user_to_view_article",
    "INTENDED_ENTITY_TYPE": {
        "PERSON": ("person", "Person"),
        "ORGANIZATION": ("organization", "Organization"),
    },
}

Choices#

This module contains the choices for the models in the django_help app.

class django_help.choices.IntendedEntityType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: TextChoices

Stores the type of entity that a category or article is intended for.

ANY = 'any'#

URLs#

URLs for django_help.