Login

Tag "partial"

Snippet List

Partial Tag

Lets you include another template and pass in named variables. Use like: {% partial field_template field=form.city %} If no key is specified, it will use "item" instead. You may pass in multiple variables as comma-separated key=value pairs.

  • context
  • partial
  • include
  • ssi
Read More

Partial templates, combine with and include

This snippet adds simple partial support to your templates. You can pass data to the partial, and use it as you would in a regular template. It is different from Django's {% include %}, because it allows you to pass a custom variable (context), instead of reusing the same context for the included template. This decouples the templates from each other and allows for their greater reuse. The attached code needs to go into templatetags folder underneath your project. The usage is pretty simple - {% load ... %} the tag library, and use {% partial_template template-name data %} in your template. This will result in template passed as template-name to be loaded from your regular template folders. The variables are passed in a with compatiable syntax, eg. VAR as NAME and VAR as NAME No limitations on the number of variables passed.

  • template
  • templates
  • partial
  • with
  • include
  • partials
Read More

partial tag

This is another partial tag, taken from a previous partial tag. The previous one assumed template locations by hardcoding in "partials/%s", etc. I took all that out, and made it work. And I took out the not needed third parameter for passing in your own data So now you call like this: {% partial "partials/mypartial.html" %} It passes the template context var into the partial, so anything you do in the main template, will work in the partial Just make sure you've got all the right imports.

  • tag
  • python
  • partial
Read More

"Partial Templates" - an alternative to "include"

This snippet adds simple partial support to your templates. You can pass data to the partial, and use it as you would in a regular template. It is different from Django's `{% include %}`, because it allows you to pass a custom variable (context), instead of reusing the same context for the included template. This decouples the templates from each other and allows for their greater reuse. The attached code needs to go into `templatetags` folder underneath your project. The usage is pretty simple - `{% load ... %}` the tag library, and use `{% partial_template template-name data %}` in your template. This will result in template passed as **template-name** to be loaded from **partials** folder. The **.html** extension will be appended to the file name. The file has to be in one of template paths accessible to the loader) and rendered with **data** as its context. The data is available in the template as an `item` context variable. You can find more information in the [relevant Django documentation](http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags)

  • template
  • tag
  • templates
  • tags
  • partial
  • include
  • partials
Read More

Instance partial update

If you're like me, you've got a models with a lot of fields/foreignkeys and often only want to edit a portion of the model in a form. Add this method to your custom form class and use it in place of the save() method.

  • forms
  • model
  • partial
  • updating
Read More

Partial OpenID provider implementation from idproxy.net

Lots of people have asked me when the [django-openid](http://code.google.com/p/django-openid/) package will provide tools for running an OpenID provider (in addition to an OpenID consumer). The answer is "when it's done", but since it's such a common request I've decided to post some example code to help people who want to work it out for themselves. This is the openidserver.py file from [idproxy.net](http://idproxy.net/). It is **incomplete** - the urlconf, models, templates and some utility functions are not included. In other words, it's useless for anything other than providing a few hints as to how you can go about implementing a provider. Nonetheless, it's better than nothing. I hope this will prove a useful example for people trying to figure out how to best integrate the JanRain Python OpenID library with Django to build an OpenID provider.

  • openid
  • incomplete
  • partial
Read More

6 snippets posted so far.