Skip to main content

A application to position objects anywhere on a page.

Project description

Backwards incompatible changes made in version 0.2.2

COMBINE_STRING is now used to build the template list when using PositionContent.render or render_content template tag.

Before:

/positions/my_position/<app>__<model>.html

New:

/positions/my_position/<app> <combine_string> <model>.html

Installation

Using PIP:

pip install django-kamasutra

or download the app here

python setup.py install

Add positions to your settings INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'positions',
    ...
)

Run syncdb:

>>> ./manage.py syncdb

Getting Started

Creating your first position

The minimum required arguments to create a positions is a name, which is a SlugField.

from positions.models import Position

position = Position.objects.create(name="MyPosition")

Add something to your Position

The position manager has a add_object method that takes, at minimum, 2 arguments, position and obj

  • position should be a positions.Position instance

  • obj can be any model instance

from myapp.models import MyApp

obj = MyApp.objects.get_latest()

Position.objects.add_object(position=position, obj=obj)

Retrieve your position content

The position manager has a get_content method that takes at least 1 argument, position.

  • position should be a positions.Position instance

position = Position.objects.get(name="MyPosition")

content = Position.objects.get_content(position=position)

Retrieve your position content via templatetag

{% get_position_content position as content %}

get_position_content expects [position] [as] [varname]

  • position can be a positions.Position instance or a name of a position

Position {{ position }} has the following content:<br/>
<ul>
{% for obj in content %}
    <li>{{ obj }}</li>
{% endfor %}
</ul>

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-kamasutra-0.2.4.tar.gz (589.9 kB view details)

Uploaded Source

File details

Details for the file django-kamasutra-0.2.4.tar.gz.

File metadata

File hashes

Hashes for django-kamasutra-0.2.4.tar.gz
Algorithm Hash digest
SHA256 9c9d97c0910715b4f1c1ff295f3b62a7162dd5df120ad7f329b9c397760b1158
MD5 45339c250740ad7904e5e4bda54857a8
BLAKE2b-256 eb682e2747c5b501b065a2fe81216f615a844a8cbd8afaaefd229746d39687d4

See more details on using hashes here.

Provenance

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