I am writing a simple web app, and I am struggling to access my variable
attributes in one of my templates. The get_object_or_404 method returns my
customized 404 error from my *content_detail.html *file: "No content is
available."
Here are my files:
*archive/archive/urls.py:*
from django.co
have reviewed the online doc sevral times now and various books
> and tutorials trying to find the answer.
>
> However, I can't seem to get my template variables to render within the
> web page (crazy I know).
>
> I've tried this many different ways and finally back
al times now and various books
> and tutorials trying to find the answer.
>
> However, I can't seem to get my template variables to render within the
> web page (crazy I know).
>
> I've tried this many different ways and finally backed-up and
> stripped-down the code
fact programming in
general. I have reviewed the online doc sevral times now and various books
and tutorials trying to find the answer.
However, I can't seem to get my template variables to render within the web
page (crazy I know).
I've tried this many different ways and finally backed-
On Fri, Jul 18, 2014 at 4:45 AM, Neto wrote:
> Using 'locals ()' would slow page loading? What is better?
>
Using locals() as template context might give you a *slight* slowdown in
template rendering (since you'll have lots of context variables that you
won't be using). However, that effect woul
Using 'locals ()' would slow page loading? What is better?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to
On 24/08/13 14:56, Ariel Calzada wrote:
you have to append strings first
http://stackoverflow.com/questions/4386168/how-to-concatenate-strings-in-django-templates
and then call trans
2013/8/24 Some Developer mailto:someukdevelo...@gmail.com>>
I have a title and a header block which norm
On 24/08/13 14:56, Ariel Calzada wrote:
you have to append strings first
http://stackoverflow.com/questions/4386168/how-to-concatenate-strings-in-django-templates
and then call trans
2013/8/24 Some Developer mailto:someukdevelo...@gmail.com>>
I have a title and a header block which norm
you have to append strings first
http://stackoverflow.com/questions/4386168/how-to-concatenate-strings-in-django-templates
and then call trans
2013/8/24 Some Developer
> I have a title and a header block which normally contain static text but
> for some pages I need to display some dynamic i
I have a title and a header block which normally contain static text but
for some pages I need to display some dynamic information contained in a
template variable.
So I might have the template variable: {{ app.name }}
and the block code:
{% block title %}
{% trans "{{ app.name }} Inf
Doh!
Thank you, sir!
On Thursday, October 4, 2012 5:17:59 PM UTC+2, Laxmikant Gurnalkar wrote:
>
> Try,
>
> cheers
> L
> On Thu, Oct 4, 2012 at 8:27 PM, Zoran Hranj
> > wrote:
>
>> Hi guys,
>>
>> basicly I want to do the following:
>>
>>
>>
>> But the "{{ item.url }}" part does not get evalua
Hi guys,
basicly I want to do the following:
But the "{{ item.url }}" part does not get evaluated. I understand why it
is not evaualted, but I want to know if there is a filter or something to
make it work like I want to (quick glance on the filter list didnt give me
any ideas).
--
You rec
Or you can render the js file as if it was a template.
Put the javascript in a template directory.
In the main HTML, change the tag to something like
On 11/25/2011 03:06 PM, Tom Evans wrote:
On Fri, Nov 25, 2011 at 11:25 AM, Alessandro Candini wrote:
Hi everybody.
I have an application with the following structure:
STO
├── __init__.py
├── jsonopenlayers
│ ├── __init__.py
│ ├── models.py
│ ├── static
│ │ ├── css
│ │ │ └── STO.css
│ │ └── js
On Fri, Nov 25, 2011 at 11:25 AM, Alessandro Candini wrote:
> Hi everybody.
>
> I have an application with the following structure:
>
> STO
> ├── __init__.py
> ├── jsonopenlayers
> │ ├── __init__.py
> │ ├── models.py
> │ ├── static
> │ │ ├── css
> │ │ │ └── STO.css
> │ │ └── js
> │ │ └── renderMap
Hi everybody.
I have an application with the following structure:
STO
├── __init__.py
├── jsonopenlayers
│ ├── __init__.py
│ ├── models.py
│ ├── static
│ │ ├── css
│ │ │ └── STO.css
│ │ └── js
│ │ └── renderMaps.js
│ ├── tests.py
│ └── views.py
├── manage.py
├── settings.py
├── templates
│ └── j
I'm a Django noob and fear the answer to my question is fairly obvious, but
hoping someone can help.
I'm building an app that includes the same form on every page, with the content
surrounding the form and the model instance to which the form data is tied
dependent on a value passed in the URL.
n Mar 20, 11:15 pm, Daniel Roseman wrote:
>
> > On Sunday, March 20, 2011 9:57:04 PM UTC, Turner wrote:
>
> > > I'm working on a custom tag to which I would like to be able to pass
> > > template variables and filters. I found
> > > Variable(value).r
On Mar 20, 11:15 pm, Daniel Roseman wrote:
> On Sunday, March 20, 2011 9:57:04 PM UTC, Turner wrote:
>
> > I'm working on a custom tag to which I would like to be able to pass
> > template variables and filters. I found
> > Variable(value).resolve(context) in th
On Sunday, March 20, 2011 9:57:04 PM UTC, Turner wrote:
>
> I'm working on a custom tag to which I would like to be able to pass
> template variables and filters. I found
> Variable(value).resolve(context) in the Django source. I
> have a couple of questions:
>
> You
I'm working on a custom tag to which I would like to be able to pass
template variables and filters. I found
Variable(value).resolve(context) in the Django source. I
have a couple of questions:
1) Is it safe to use Variable()? That is, is it part of
the public API? Not having visibility modi
Hi,
Just want to know if this is the correct understanding of how model
instances are passed to templates.
If I load a model instance object into a template - is it the case
that I also implicitly load in any instance objects it is related
through foreign key fields? It seems that these, and in t
:)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group a
alright, thanks a lot Syed :P
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more
dude I missed 1 important import.
first add this,
-
from django.template import RequestContext
also makesure your template path is set in settings.py
mine looks something like this
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templa
thanks, unfortunately i keep getting a 404, the templates name is
2col.html, its inside ash/templates, the url i have is (r'^paragraph/
$', 'show_para'), and the views is
from django.http import HttpResponse
from django.shortcuts import render_to_response
def show_para(request):
para = "I lo
you can use django render_to_response which by far the most common and
preferred way, i found as newbie my self.
here is an example: (roughly but will give you an idea)
---
Now following this is an extremly crude tut by myself, for a superb one
hey guys, im trying to create a template that uses variables like
{{ paragraph }} , but i cannot find how to get django to render
the paragraph into the variable, i know i have to create a .py file
that uses django's render class to render the paragraph but how can i
connect the html file to the .p
For those interested:
In my base template I've added this:
{% load custom_tags %}
{% if form %}
{% formerrors request form %}
{% endif %}
In my custom_tags template tags library:
@register.simple_tag
def formerrors(request, form):
for field, errors in form.errors.items():
for er
I'll explain a bit more what precisely it is what I want to do: Django
1.2 comes with a new messages framework that allows for each message
to have a different "level" (succes, error, warning, etc). I want to
see if a form has errors, and if so, make a message for each error so
all my notices and e
Write your new view so that it can be used generically.
On Thu, Mar 4, 2010 at 10:22 AM, Kevin Renskers wrote:
> Well yes, but I do not want to change all of my views. I want a
> generic solution to change template variables before they get
> rendered.
>
>
> On Mar 4, 4:1
Well yes, but I do not want to change all of my views. I want a
generic solution to change template variables before they get
rendered.
On Mar 4, 4:14 pm, Bill Freeman wrote:
> Write your own view instead of using direct_to_template.
>
>
>
> On Thu, Mar 4, 2010 at 10:06 AM,
Write your own view instead of using direct_to_template.
On Thu, Mar 4, 2010 at 10:06 AM, Kevin Renskers wrote:
> Hi,
>
> I am wondering if it is possible to change template variables before
> they get rendered in a template.
>
> For example, I use something like this in my
Hi,
I am wondering if it is possible to change template variables before
they get rendered in a template.
For example, I use something like this in my template:
return direct_to_template(request, template='index.html',
extra_context={'form':form})
I would like to exten
Exactly. Thanks.
On Nov 21, 4:45 pm, Tim Chase wrote:
> > When I do in a template I get > id="item_1"> in the rendered html as expected.
>
> > Now I want to do {% cycle '' ' > class="odd" id="item_{{ product.id }}">' %}, but the desired
> > concatenation does not happen.
>
> > How do I achieve
> When I do in a template I get id="item_1"> in the rendered html as expected.
>
> Now I want to do {% cycle '' ' class="odd" id="item_{{ product.id }}">' %}, but the desired
> concatenation does not happen.
>
> How do I achieve what I want?
sounds like you want something like
-tim
Hi,
When I do in a template I get in the rendered html as expected.
Now I want to do {% cycle '' '' %}, but the desired
concatenation does not happen.
How do I achieve what I want?
Regards.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
T
This is a general question. I think it would be useful to be able to
use template variables as filters. Consider the following: I need to
display dates according to a user's timezone. My options are to create
these translated dates in the view code (assign them to model
instances or create
Thanks Alex. I'll give it a try. I appreciate your comments.
On Wed, Jun 10, 2009 at 5:49 AM, Alex Robbins wrote:
>
> I haven't used that form plugin before, but from the documentation it
> looks like the problem is this line:
> target:"#new",
> http://malsup.com/jquery/form/#options-object
> Yo
I haven't used that form plugin before, but from the documentation it
looks like the problem is this line:
target:"#new",
http://malsup.com/jquery/form/#options-object
You are asking jQuery to jam the whole response in, just like you are
seeing. What happens if you take that line out? It looks lik
I'm new to programming and can't figure out how to properly render the
{{comment}} and {{username}} variables in the element
below using jquery and the ajax form plugin. Everything posts to the
database just as it should. However, I want to show what gets posted
in the template after submission.
"], post[regular-title], post.regular-
> > title and so on, and searched around the docs and mailing lists, but
> > haven't found any answers.
>
> > Is there a way to print template variables with "-" in their names?
>
> Django templates don't
ango
> templates since regular-title is an invalid variable name. I've tried
> stuff like: post["regular-title"], post[regular-title], post.regular-
> title and so on, and searched around the docs and mailing lists, but
> haven't found any answers.
>
> Is ther
having trouble printing this in the django
> templates since regular-title is an invalid variable name. I've tried
> stuff like: post["regular-title"], post[regular-title], post.regular-
> title and so on, and searched around the docs and mailing lists, but
invalid variable name. I've tried
stuff like: post["regular-title"], post[regular-title], post.regular-
title and so on, and searched around the docs and mailing lists, but
haven't found any answers.
Is there a way to print template variables with "-" in their names?
--~--~-
Might not be the easiest way, but you could use a custom filter:
def formsbyfield(forms,field):
""" Given a list of similar forms, and a field name,
return a list of formfields, one from each form.
"""
return [form.fields.get(field,'') for form in forms]
register.filter('forms
I have a list of forms, all of the same type, where I would like to
list each form side by side with the fields listed vertically. The
root of the problem is that I need to use a template variable as an
index on another template variable. Something like this.
{% for field in forms.0 %}
{{
Hello,
i'm trying to use formwizard for my project, but i can't seem to solve
the problem. I have two step formwizard, and i need a variable from
first step to show up in the next.
Second step is a queryset of "available texts" - and there is a
"name" ( lets say {{ name }}) variable in it, that n
I think I got it! Wrong ordering of middleware - I had the i18n-urls
middleware before some other stuff, which screwed up a lot... It's
working now, and my hair will probably grow back eventually...
//emil
On Jan 11, 12:41 pm, Emil <[EMAIL PROTECTED]> wrote:
> Nope, that doesn't seem to be it -
Nope, that doesn't seem to be it - same problem with dummy caching on
dev server. More likely the culprit is the Advanced Locale From URL
Middleware I'm using[1]. I inspected the response headers I get, and
even if the language is set to English on the site, response headers
always show Content-La
Hi Peter,
thanks for the tip, I'm reading up on the vary_on_headers-decorator
right now, I'm gonna see if that clears things up. Just seems weird
from my reasoning, and another project I'm working on doesn't have
this problem, with nearly excactly the same setup. Oh well, I'll poke
around and see
Emil:
> Except that on a couple of pages,
> the language seems to get stuck on the translated language after the
> first time I change languages.
This smells very much like a caching issue. Do you have any form of
caching enabled? If so, turn it off and see if the problem is
magically fixed.
Yo
Hi folks,
I have a rather peculiar problem. I created translations for my
project, and mostly they work fine. Except that on a couple of pages,
the language seems to get stuck on the translated language after the
first time I change languages.
Example: I visist the site. It's in english (which i
On Oct 13, 8:09 am, Goon <[EMAIL PROTECTED]> wrote:
> can you use variables in django's templates?
>
> so like {% for x in y %}
>
> and then something like
>
> {% int x =3; x++ %}
Recently I found some handy django snippet which can be usefull for
you.
http://www.djangosnippets.org/snippets/9/
On Oct 13, 8:35 pm, "Nikola Stjelja" <[EMAIL PROTECTED]> wrote:
> On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
>
> What's the problem. You just send the template 'y':range(1,6). It's very
> simple. I don't think the template syste
On Oct 13, 3:41 am, Goon <[EMAIL PROTECTED]> wrote:
> Ok, but let's say I have a template like {{for x in y}}, and I would
> like the x's seperated by commas, but I don't want a comma after the
> last one? or better yet cut off after the first 100 characters with a
> "..."
The key here is that
On 10/13/07, beck917 <[EMAIL PROTECTED]> wrote:
>
> Maybe use the custom template filters is a nice way~
>
> http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters
>
Yep. The point is: less programming in html, the better. That's the reason
most experienced p
Maybe use the custom template filters is a nice way~
http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters
2007/10/13, Nikola Stjelja <[EMAIL PROTECTED]>:
>
>
>
> On 10/13/07, James Bennett <[EMAIL PROTECTED]> wrote:
> >
> >
> > On 10/13/07, Goon <[EMAIL PR
On Oct 13, 3:26 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
>
> > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
>
> Perhaps the documentation will make you happy:
Ok, but let's say I have a template like {{for x in y}}, and I
On 10/13/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
What's the problem. You just send the template 'y':range(1,6). It's very
simple. I don't think the template system should be
On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
Perhaps the documentation will make you happy:
http://www.djangoproject.com/documentation/templates/#slice
--
"Bureaucrat Conrad, you are technically correct -- the best kind of corre
fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
dammit!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To un
On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> can you use variables in django's templates?
Yes.
> and then something like
> {% int x =3; x++ %}
No.
Django's template language is not Python or any other programming
language. Its sole purpose is presentational logic.
--
"Bureaucrat Conrad,
Simple answer is no. But you can may be try porting mako to to django
On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
>
>
> can you use variables in django's templates?
>
> so like {% for x in y %}
>
> and then something like
>
> {% int x =3; x++ %}
>
> or something like that, would be mighty helpful
can you use variables in django's templates?
so like {% for x in y %}
and then something like
{% int x =3; x++ %}
or something like that, would be mighty helpful
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"
On Jul 30, 7:42 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
>
>
try to pprint the variables you pass the template directly in the view
fonction they will appear in the console if you use the django dev
server :)
--~--~-~--~~~---~--~~
You received th
Welcome !
On Jul 30, 2:01 pm, "Peter Melvyn" <[EMAIL PROTECTED]> wrote:
> On 7/30/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> > Try {% debug %}
>
> If you mentioned this feature: is there an easy way to reformat {%
> debug %} output the same/similiar way an exception error is reported?
On 7/30/07, Peter Melvyn <[EMAIL PROTECTED]> wrote:
>
> On 7/30/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> > Try {% debug %}
>
> If you mentioned this feature: is there an easy way to reformat {%
> debug %} output the same/similiar way an exception error is reported?
Not easily. {% de
On 7/30/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
> Try {% debug %}
If you mentioned this feature: is there an easy way to reformat {%
debug %} output the same/similiar way an exception error is reported?
Peter
--~--~-~--~~~---~--~~
You received this me
Russell Keith-Magee escribió:
> On 7/30/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
>
>> I didn't know of that function. Nice to know. But, is there a var where
>> to access *all* the vars available in the template and it's contents?
>> I've been needing that one for debugging for ever!
>>
On 7/30/07, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
>
> I didn't know of that function. Nice to know. But, is there a var where
> to access *all* the vars available in the template and it's contents?
> I've been needing that one for debugging for ever!
Try {% debug %}
http://www.djangoproject.
Nathan Ostgard escribió:
> Try: {{ data|pprint }}
>
> On Jul 29, 10:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
>> I'm coming from CakePHP and I would typically set a variable for use
>> in my view with a call to findAll. Since there is a lot of data in the
>> array, I typically do
Try: {{ data|pprint }}
On Jul 29, 10:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I'm coming from CakePHP and I would typically set a variable for use
> in my view with a call to findAll. Since there is a lot of data in the
> array, I typically do something like:
>
>
>
>
>
> This wa
I'm coming from CakePHP and I would typically set a variable for use
in my view with a call to findAll. Since there is a lot of data in the
array, I typically do something like:
This way, I can find out what data is available in the view and figure
out how much I can scale back the recursion.
ng it:
Basically, I want to manage my templates in the admin view, and have
the ability to define custom variables to be filled out.
Then, in say, the "Instance" admin add page, the user is able to
select a template. The page will then dymaically generate a table of
the template va
Hi Patrick,
You might find some helpful responses in this thread:
http://groups.google.com/group/django-users/browse_frm/thread/50ee1c147854769/a79890af3059229d?q=menu&rnum=3#a79890af3059229d
On 6/20/06, Patrick <[EMAIL PROTECTED]> wrote:
>
> Hi i'm newbie and i want to publish my Django websit
Hi i'm newbie and i want to publish my Django website.
I have this "stupid" problem.
I have a tab bar like this:
Home^M
Blog^M
Tags^M
Blank^M
You could define a filter "lookup":
from django.core.template import resolve_variable, Library
register = Library()
def lookup(value, arg):
return resolve_variable(arg, value)
register.filter(lookup)
and use it in your code like this:
{%for r in object_list %}
{%for c in field_lis
i am trying to make a table template similar to what i find for inline
editable modules in the admin interface.
I want to send a list of (same class) objects and fields of those
objects and then get a row for each object with a col for each desired
field. I thought this would be easy because it
excellent - thanks. (it is very easy) ...
Alice
On Sat, 14 Jan 2006 16:12:50 - Alice wrote:
> I just finished writing the tag and realized that it won't work unless
> I can access the data passed to the template. Any help in getting
> around this (probably simple) problem would be welcome.
The 'render' method of custom tag gets passed the
Alice wrote:
Is there a means to pass a template variable {{ user_id }} to a custom
template tag,
{% build_menu "user_id" %} ?
In fact you can treat anything after your tag name as you like, it's
just a string. But for such natural thing as treating it as a variable
Django will help. For t
Is there a means to pass a template variable {{ user_id }} to a custom
template tag,
{% build_menu "user_id" %} ?
I just finished writing the tag and realized that it won't work unless
I can access the data passed to the template. Any help in getting
around this (probably simple) problem would be
83 matches
Mail list logo