It seems most documentation recommends :
template_values = {}
template_values["foo"] = "bar"
return render_to_response(path, template_values, context_instance=RequestContext(request)
Why don't I use :
template_values = RequestContext(request)
template_values["foo"] = "bar"
return render_to_response(path, template_values)
...
I'm trying to do pagination with the page parameter in the URL (instead of the GET parameter). I also want my pagination to be shared code across multiple different templates.
Given that, I think I need to do something like this :
urls.py:
url(r'^alias/page;(?P<page>[0-9]+)/(?P<id>.*)$', alias.get, name="alias"),
tempaltes/alias.htm...
Good Morning All,
I've been a PHP programmer for quite some time, but I've felt the need to move more towards the Python direction and what's better than playing around with Django.
While in the process, I'm come to a stopping point where I know there is an easy solution, but I'm just missing it - How do I display manytomany relationsh...
If fruits is the list ['apples', 'oranges', 'pears'],
is there a quick way using django template tags to produce "apples, oranges, and pears"?
I know it's not difficult to do this using a loop and {% if counter.last %} statements, but because I'm going to use this repeatedly I think I'm going to have to learn how to write custom tags f...
Hi guys, in django admin the views that show the register's just have
a link to "edit", but what happen if a need an extra(S) links to
another views?
for example:
i have view that show the list of registered People, the nick is
linking to the Edit page (the normal way of Django), but i need
another links that will show me the "arti...
I'm trying to create a simple Django multi-page form using FormWizard. What the form should do is the following:
Let the visitor enter first and lastname in a form.
Continue to next page where entered previously firstname and lastname will be displayed, there will also be a field on this page that let's the visitor enter a message.
The...
I find django's template language very limiting. Following along with django's DRY principle, I have a template that I'd like to use in many other templates. For example a patient list:
{% for physician in physicians.all %}
{% if physician.service_patients.count %}
<div id="tabs-{{ forloop.counter }}">
{% include "hospitalists...
Hi guys, im trying to use the Tiny MCE editor in my FlatPages, but the Editor dont appear and the css of the add form in flatpage is broken.
im using in this way:
url.py
(r'^tiny_mce/(?P<path>.*)$','django.views.static.serve',{'document_root': 'e:/wamp/www/diligencia/src/tiny_mce/jscripts/tiny_mce/'}),
template:
template overriding...
Hello,
I need to retrieve an optional number saved in DB , to a custom template tag i made . which to retrieve , a variable ( a photo ID ) included in this Gallery . within the gallery loop .
{% get_latest_photo {{photo.id}} %}
How to accomplish that ?!
P.s : I know that can be done with inclusion tag , but in the present time h...
Hi guys, im asking again :), i like that!!! jeej, im learning Django :D
Well, i have a few flatpages in my app menu, so, my question is, how ill pass variables to my flatpages if i dont have any view for flatpages?
here my url.py
(r'',include('django.contrib.flatpages.urls')),
i dont have any view's for any flatpages, so i dont know...
So, I've been noodling about with Django's generic views, specifically the object_list view. I have this in my urls.py:
from django.conf.urls.defaults import *
from django.views.generic import list_detail
from diplomacy.engine.models import Game
game_info = {
"queryset": Game.objects.filter(state__in=('A', 'P')),
"template_obj...
Typically when you want to mark string output as safe in Jinja2 you do something like this:
{{ output_string|safe() }}
However, what if output_string is always safe? I don't want to repeat myself every time by using the safe filter.
I have a custom filter called "emailize" that preps urls for output in an email. The ampersands always...
Well, im out my mind of what jeje .... how ill evaluate a variable with {% if %} in template?
im trying this
{% if variable > 0 %} or {% if variable != 0 %}
but...i got errors :(
Thanks
...
Hi guys, i have a question about the choices option field.
i have this field:
SECUENCIA = (
('1','1'),
('2','2'),
('3','3'),
)
secuencia = models.IntegerField(max_length=1,choices=SECUENCIA)
All is fine in my forms for add or update but in my show view (template display) the field just appear li...
I've got a Model in Django, example code below (not my actual code):
class Department(models.Model):
name = models.CharField(max_length=100)
abbreviation = models.CharField(max_length=4)
Let's say I do the following in the Django shell:
>>> Department(name='Computer Science',abbreviation='C S ').save()
>>> Department(name='Ma...
Hi Guys,
I know django purposely does not allow a whole lot of logic in the templates. However sometimes you are required to evaluate something and based on that change your options.
How do you change a value in a template or insert something only if it's the first record? But you would still like to loop through the rest. For example...
I need to create a cross-site template object which will check the current time and return either one string if it's within a time range specified in a model or another or blank in all other cases.
Seems simple, but I wonder what is the best approach here? Also, there are a few other considerations:
the string should be editable
the d...
Hi guys, how ill show in the admin section the user picture?, i was looking the template of the admin and i can't see how...
i think that Django show the fields in the section code (change_list template), but jeje ..how? jeje
{% block result_list %}
{% if action_form and actions_on_top and cl.full_result_count %}{% admin_acti...
http://www.djangobook.com/en/beta/chapter10/
"Note that django.core.exceptions.ObjectDoesNotExist, which is the base class for all Django database API DoesNotExist exceptions, has silent_variable_failure = True. So if you’re using Django templates with Django model objects, any DoesNotExist exception will fail silently."
Whilst I'm dev...
We know about "extend" inheritance tag and inclusion tags. What about the combination of it, like an asp.net grid templates.
Like this:
{% template %}
{% content top %}some html{% endcontent %}
{% content bottom %}some html{% endcontent %}
{% endtemplate %}
UPD:
Is there such tags already developed?
...