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.
...
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>
Is there something I can...
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
...
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...
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...
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):
...
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?
...
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...
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.
...
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...
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...
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.
...
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...
I'd like to deliver special versions of my django site for different (mobile-)browser.
What are possible solutions to do this?
...
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
...
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...
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:
...
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...
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.
...
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...