A Django application containing a set of abstract classes to implement a set of highly manageable sections with any content
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-appchance-sections-0.3.tar.gz
.
File metadata
- Download URL: django-appchance-sections-0.3.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17a52fe16569f3f799dd53ff9a6558571f6cf01c67fbb17229a8ba933b3b093e |
|
MD5 | 7fb89faece6f2f379507813a675097ab |
|
BLAKE2b-256 | a768d48b676d0b902ab4a30bd393cbb885eb8d7587b7dc8a3e23a4436725156e |
File details
Details for the file django_appchance_sections-0.3-py3-none-any.whl
.
File metadata
- Download URL: django_appchance_sections-0.3-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc8a6ed76d0a90ea4520a59c740d8ab7ca324cf56653cee6ccdb9602089c4ac9 |
|
MD5 | 2a0fe4a8cff1cd22d197e9e6bd767ddd |
|
BLAKE2b-256 | 1631a62c75a39703e8c192f9cd3bc5596afff068e5df2ac7bae8479c755d37a2 |