django-templates

Django -- Python -- How to have a global templatetags shared among all my apps in one project

Hi, Let say that I have: proj1/app1 proj1/app1/templatetags/my_shared_tags.py proj1/app2 proj1/templates proj1/templates/app1/index.html proj1/templates/app2/index.html Now, how can I reuse a tag from my_shared_tag.py from app1 in my app2. ...

Is is possible to html encode output in AppEngine templates?

So, I'm passing an object with a "content" property that contains html. <div>{{ myobject.content }}</div> I want to be able to output the content so that the characters are rendered as the html characters. The contents of "conent" might be: <p>Hello</p> I want this to be sent to the browser as: pHello/p&gt; Is there something I can...

Django -- How to have a project wide templatetags shared among all my apps in that project

Second time asking more details ... I'd like to have a project wide templagetags directory to have the common tags used by all Apps, then each app can have their own tags if need so. Let say that I have: proj1/app1 proj1/app1/templatetags/app1_tags.py proj1/app2 proj1/app2/templatetags/app2_tags.py proj1/templatetags/proj1_tags.py ...

How do I get the server name in Django for a complete url?

I'm using django templates to create an e-mail. I do something like this: msg_html = render_to_string('email/%s.html' % template_name, context) msg = EmailMultiAlternatives(subject, msg_text, from_email, to_list) msg.attach_alternative(msg_html, "text/html") msg.content_subtype = "html" msg.send() My template uses named url patterns l...

Django -- how to templatetags filter with multiple arguments

I have a few values that I would like to pass into a filter and get a URL out of it. In my template I have: {% if names %} {% for name in names %} <a href='{{name|slugify|add_args:"custid=name.id, sortid=2"}}'>{{name}}</a> {%if not forloop.last %} | {% endif %} {% endfor %} {% endif %} In my templatetags I have: @registe...

Django Templates — passing value of a variable in a template to templatetags filter

name class an id, a first & a last attributes In my view.py, I fetch a name object from the database and pass it into the index.html template. In my templagetags/my_tags.py, I have a filter my_private_tag(value, arg) that takes value and an arg. It appends the arg to the value and returns the result. def my_private_tag(value, arg): ...

How to use inbulit django templatetags in google-app-engine

I am trying to use Django in built templatetags like markup and humanize in my google app , but its not working. I added markup and humanize in the INSTALLED_APPS. Still not working. How to use that? ...

How do I include image files in Django templates?

I'm new to Django and I'm trying to learn it through a simple project I'm developing called 'dubliners' and an app called 'book'. The directory structure is like this: dubliners/book/ [includes models.py, views.py, etc.] dubliners/templates/book/ I have a JPG file that needs to be displayed in the header of each Web page. Where shoul...

How Can I Check the Size of a Collection with Django Templates?

I have a list in my Django template. I want to do something only if the size of the list is greater than zero. How can I check this? I have tried myList|length and myList|length_is but have not been successful. I've searched all over and don't see any examples. ...

Django, custom template filters - regex problems

I'm trying to implement a WikiLink template filter in Django that queries the database model to give different responses depending on Page existence, identical to Wikipedia's red links. The filter does not raise an Error but instead doesn't do anything to the input. WikiLink is defined as: [[ThisIsAWikiLink | This is the alt text]] Her...

Need a hint on what that error all about

Hello! I am having a rather weird problem in a sense that I can't understand what it might be. My site uses django-registration and all works fine, but if I restart django dev. server in the middle of the session (i.e. been logged in) I immediately get error: Caught an exception while rendering: Reverse for 'django.contrib.auth.decorat...

template django

how can i use different template in different application.in a project i have two app 1)Site 2)Ad .I want to use default template in Ad but different in Site..How to ?OR in the template is there is a way to use 'if condition' as i have to change only two lines in the templates. ...

Django question: how can I get user specific information related to a domain object?

Here are my models: class Activity(models.Model): title = models.CharField(blank=False, max_length=100) description = models.TextField(blank=False) class UserActivityWork(models.Model): activity = models.ForeignKey(Activity) user = models.ForeignKey(User) hours_worked = models.FloatField() comment = models.Tex...

How to use different template for different browser

I'd like to deliver special versions of my django site for different (mobile-)browser. What are possible solutions to do this? ...

using "range" in a google app engine template for - loop

hi, i've got an appengine project and in my template i want to do something like {% for i in range(0, len(somelist)) %} {{ somelist[i] }} {{ otherlist[i] }} {% endfor %} i've tried using 'forloop.counter' to access list items too, but that didn't work out either. any suggestions? regards, mux ...

Why can't I nest a block tag inside an if tag?

I have a master template file called base.html, in it I have the following code: {% ifequal environment "dev" %} {% block stylesheets %}{% endblock %} {% endifequal %} I inherit this in other templates and do the following: {% block stylesheets %} <link ... > {% endblock %} The problem is, the stylesheet I link never gets a...

Django model inheritance w/ custom inclusion_tags

I'm gonna try and simplify this as much as possible. Lets say i have the following: models.py class Person(models.Model): name = models.CharField(max_length=255) def getRealPerson(self): # is there a better way to do this? ret = None try: ret = self.worker except: try: ...

JSP Custom Tags: Is it possible to have a more than start / close tags?

After using the Django template language, I really miss being able to do things like this: {% if condition %} <!-- snip --> {% else %} <!-- snip --> {% endif %} When I am using JSP, I am stuck doing something like this: <logic:equal name="something" value="example"> <!-- snip --> </logic:equal> <logic:notEqual name="somet...

how to disable bulk_action in django 1.1 beta

Hi, I am using django 1.1 beta release. In my project I want to use bulk_action in some models only. How can I disable bulk_action from the remaining models? I want to totally remove action label along with the checkbox; in other words as it would look in Django 1.02. ...

How to split render django's ModelMultipleChoiceField in template file?

I want to make (ordered) Song list form. models.py class Song(models.Model): title = models.CharField(max_length=60) class List(models.Model): title = models.CharField(max_length=100) songs = models.ManyToManyField(Song, through='Order') class Order(models.Model): list = models.ForeignKey(List) song = models.Forei...