Skip to content

ihalaij1/django-dictiterators

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django dict iterators

Simple template related tools to handle iterators with more complex data than just model objects.

You would have something like following in your views.py

context['data'] = (
    {
        'obj': obj,
        'form': Form(instance=obj),
        'post_url': reverse('post_to', kwargs={'pk': obj.pk}),
    } for obj in object_list
)

And then this in your template

{% load dictiterators %}

{% foreachdict in data %}
    <h1> {{ obj.title }} </h1>

    <form action="{{ post_url }}" method="post">
        {{ form }}
    </form>
{% endforeachdict %}

For above to work add django_dictiterators in your django projects settings INSTALLED_APPS list.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.1%
  • Shell 0.9%