Skip to main content

Appchance Sections

This application will allow you to implement flexible sections. It is not an out of the box mechanism and its implementation requires a bit of effort, but in return you get a solution that you can relatively easily adapt to your needs.

Including:

  • the possibility of generic and dynamic content,
  • convenient operation in the admin panel.

This solution was designed for the Django Rest Framework.

Not so quick start

The application appchance_sections contains only abstract models so you nead add new application

    python manage.py startapp mysections

add created app to settings.INSTALLED_APPS

    INSTALLED_APPS = [
        ...
        'mysections',
    ]

and define real models.

1. Real Section Model

In mysections.models.py file define Section model. If you need you can add additional fields, but the default fields provide basic functionality.

    from appchance_sections.models import SectionAbstract
    from django.db import models
    
    class Section(SectionAbstract):
        pass

In your Django project settings file define Section model.

SECTION_MODEL = "mysections.Section"

In mysections.admin.py use SectionAdminMixin which binds - most importantly - the modified form.

    from appchance_sections.admin import SectionAdminMixin
    from django.contrib import admin
    from mysections.models import Section

    @admin.register(Section)
    class SectionAdmin(SectionAdminMixin):
        pass

In mysections.apps.py it is very important that you do not forget to import appchance_sections.receivers in the config

    from django.apps import AppConfig
    
    class SectionsConfig(AppConfig):
        name = "mysections"
    
        def ready(self):
            from appchance_sections import receivers  # noqa F405

The last thing you have to do is add urls to urls.py

    from django.contrib import admin
    from django.urls import include, path
    
    urlpatterns = [
        path("admin/", admin.site.urls),
        path("", include("appchance_sections.urls", namespace="sections")),
    ]

2. Bind content

Then we need some content that we could present in sections. We can add two types of content:

  • generic
  • dynamic

To see how to define dynamic content and how to make this content possible to attach to the section.

Read more in /docs/DYNAMIC_CONTENT.md and /docs/GENERIC_CONTENT.md.

Sections were originally designed such that the section content is geted asynchronously by separate requests from the api. However, it is possible to get the content of the sections together with the list of sections.

How to? Read in /docs/IMMEDIATE_CONTENT.md

Metadata

Release files for django-appchance-sections 0.3

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-appchance-sections 0.3
File Size Uploaded
django-appchance-sections-0.3.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-appchance-sections 0.3
File Interpreter ABI Platform
django_appchance_sections-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 24.0 kB

Release files / django-appchance-sections-0.3.tar.gz

Download URL django-appchance-sections-0.3.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
17a52fe16569f3f799dd53ff9a6558571f6cf01c67fbb17229a8ba933b3b093e
BLAKE2b-256 checksum
How to use checksums
a768d48b676d0b902ab4a30bd393cbb885eb8d7587b7dc8a3e23a4436725156e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.12.0 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.4

Release files / django_appchance_sections-0.3-py3-none-any.whl

Download URL django_appchance_sections-0.3-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc8a6ed76d0a90ea4520a59c740d8ab7ca324cf56653cee6ccdb9602089c4ac9
BLAKE2b-256 checksum
How to use checksums
1631a62c75a39703e8c192f9cd3bc5596afff068e5df2ac7bae8479c755d37a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.12.0 pkginfo/1.8.3 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2

2 release files

0.1

2 release files

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