Skip to main content

Django models to allow Admin-accessible global site parameters

Project description

Site Parameters

Site Parameters is a simple Django app to store customized site-level content, so that it can be maintained from the Admin by content managers.

This includes:

  • Basic "key, value" settings for common data types;
  • Simple Navigation menus;
  • Management of Social Media locations for the site.

All data are available to all templates through a context processor.

As an example, you can have your site's copyright message as a SiteParameterString object rather than hard-coding it into a global footer template. Or, you can upload a "site canonical image" that would be used as a placeholder in situations where an image in a template isn't available.

Quick start

  1. Add "site_parameters" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
        ...
        'site_parameters',
    ]
    
  2. Add the context_processors to the system context_processors in the settings file like this::

    TEMPLATES = [
        {
                ...
                'OPTIONS': {
                        'context_processors': [
                                ...
                                'site_parameters.context_processors.get_custom_site_parameters',
                        ]
                        ...
                },
                ...
        }
    ]
    
  3. Run python manage.py migrate to create the database tables.

  4. Start the development server and visit http://127.0.0.1:8000/admin/ to see the available models.

Basic Site Parameters

You can add site parameters of the following types:

  • Integers
  • Strings
  • Text blocks
  • URLs
  • Switches (booleans)
  • Images

(At present, there's no Markdown or HTML support as both of these would require other components to be installed.)

In general, each has the following fields:

  • Title
  • Slug (automatically generated from the title, but can be over-ridden)
  • Value

The title (for the most part) is just to make it easy to remember what the parameter is for (although it can be used in templates, etc. in the "regular" way).

The slug is what's used in the global context for all templates. Any hyphens are converted to underscores. So if you have a Site: String with:

  • title = "Copyright Notice"
  • slug = "copyright-notice", and
  • value = "2019 Skepsis Interplanetary"

then you can use {{ site_parameter_string.copyright_notice }} in any template.

Social Media

The Social Media model holds information about your site's external social media pages. This is a convenience for being able to, e.g., manage lists of social media icons on pages, easily add or delete them as new services emerge and become popular, etc.

Each of the items in the Social Media list have a field to enter an SVG icon.

The "Order in List" field handles ordering.

The "Available" field handles which items will be shown on the site.

In templates, you can access the information from {{ global_social_media_dict.slug }}.

Navigation

Navigation Menus are constructed by assembling sets of Navigation Items. You can have as Navigation Menus as you need.

If you are also using Django CMS: the URL Slug field can be used to reference CMS Page objects. Otherwise you can put in a root-relative URL in the Internal Link field.

The ordered list of navigation items can be accessed in a template from the context name global_nav_ + slug, e.g., global_nav_footer.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-site-parameters-0.1.4.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

django_site_parameters-0.1.4-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file django-site-parameters-0.1.4.tar.gz.

File metadata

  • Download URL: django-site-parameters-0.1.4.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for django-site-parameters-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f7554882ad6d8cad9d2e35a3eeed363729008454f705f4820eef77da332bc251
MD5 74cd8a1531fde0e8c1e174983190d463
BLAKE2b-256 d86e2afb7ac95912c526f56f68db7885bcd283646903a837d3a14324bfb74b34

See more details on using hashes here.

File details

Details for the file django_site_parameters-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: django_site_parameters-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for django_site_parameters-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 66892d4e6b44730d72a2de430193e318e1c4e0b0aefb432cb3cc94d3ce0219d9
MD5 f8ba6b49ad56c3552840a24e3e620995
BLAKE2b-256 043c729ff4a6378789225263299163bad18192ecb4899c8eb126eec956c9ae9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page