Skip to main content

Collection of simple django tags and filters.

Project description

django-simple-tags

Collection of simple django tags and filters.

Install

pip install django-simple-tags

Installed Tags or Filters

  • Tags
    • sprintf
    • string_format
    • admin_url
    • if_cookie
    • get_cookie
    • has_cookie
    • if_setting
    • get_setting
    • has_setting
    • model_select_include
  • Filters
    • add_string_gap
    • add_string_left_gap
    • add_string_right_gap

Settings

pro/settings.py

INSTALLED_APPS = [
    ...
    'django_simple_tags',
    ...
]

Usage

{% load django_simple_tags %}

{% load django_simple_tags %}

<h1>{% sprintf "hello %s" "Tom" %}</h1>

<h1>{% string_format "hi {0}" "Tom" %}</h1>

<h1>{% string_format "hi {name}" name="Tom" %}</h1>

<h1>{% string_format "{0} + {1} = {result}" 3 4 result=7 %}</h1>

<a href="{% admin_url cat "change" %}">{% admin_url cat "change" %}</a>

<h1>{% if_cookie request "sessionid" "存在sessionid" "不存在sessionid" %}</h1>

<h1>{% get_cookie request "sessionid" %}</h1>

<h1>{% has_cookie request "sessionid" as has_sessionid %}{% if has_sessionid %}存在sessionid{% else %}不存在sessionid{% endif %}</h1>

<h1>{% if_cookie request "xsessionid" "存在xsessionid" "不存在xsessionid" %}</h1>

<h1>{% get_cookie request "xsessionid" "None" %}</h1>

<h1>{% has_cookie request "xsessionid" as has_xsessionid %}{% if has_xsessionid %}存在xsessionid{% else %}不存在xsessionid{% endif %}</h1>

<h1>{% if_setting "DEBUG" "存在DEBUG" "不存在DEBUG" %}</h1>

<h1>{% get_setting "DEBUG" %}</h1>

<h1>{% has_setting "DEBUG" as has_debug %}{% if has_debug %}存在DEBUG{% else %}不存在DEBUG{% endif %}</h1>

<h1>{% if_setting "NO_DEBUG" "存在NO_DEBUG" "不存在NO_DEBUG" %}</h1>

<h1>{% get_setting "NO_DEBUG" False %}</h1>

<h1>{% has_setting "NO_DEBUG" as has_no_debug %}{% if has_no_debug %}存在NO_DEBUG{% else %}不存在NO_DEBUG{% endif %}</h1>

{% model_select_include cat "hello.html" %}

{% model_select_include cat "world.html" %}

{% model_select_include cat "hi.html" %}

<h1>{% sprintf "Select%sto view" "Category"|add_string_gap:" " %}</h1>

<h1>{% sprintf "Select%sto view" "Category"|add_string_left_gap:" ["|add_string_right_gap:"] " %}</h1>

Releases

v0.2.0 2020/02/23

  • Fix document.
  • Remove print statements.
  • Add filters: add_string_gap, add_string_left_gap, add_string_right_gap.

v0.1.0 2020/02/23

  • First release.

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-simple-tags-0.2.0.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file django-simple-tags-0.2.0.tar.gz.

File metadata

  • Download URL: django-simple-tags-0.2.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for django-simple-tags-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3cac87b8dffe371bd00633dd51bdce4afdcf3bcdd645555b9c029eecff2d3350
MD5 51396217fc0813395ede8630eaa55379
BLAKE2b-256 6067376d680b3088ec510127a1394f311ec9e51114dfbfcdddb7b74a210afa96

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