Re: Problems displaying image objects in a Django template using a custom template tag? (coding included)

2010-10-20 Thread werefr0g
Hello, I think you should use something like alt="{{ object.title }}" /> in your template: you want to output images' url in your template, not the "object" itself. You'll find explanations in [1] and [2]. Regards [1] http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.

Problems displaying image objects in a Django template using a custom template tag? (coding included)

2010-10-20 Thread tricks...@googlemail.com
I have the following code that fails to display object images. But displays normal images fine. My Model class News(models.Model): title--- image = models.ImageField(upload_to='images') body Template tag coding from django import template register = template.Library() from -

Re: Django template : For Loop

2010-09-06 Thread Tim Chase
but is this correct way to get values from two tables and use in templates? Me actually want to combine to tables and use there values in template Is the above post code is correct way to do this? Combine the in the *view* with the zip() built-in, and use Steve's suggestion to split the part

Re: Django template : For Loop

2010-09-06 Thread Jagdeep Singh Malhi
> but is this correct way to get values from two tables and use in > templates? Me actually want to combine to tables and use there values in template Is the above post code is correct way to do this? Thanks -- You received this message because you are subscribed to the Google Groups "Django

Re: Django template : For Loop

2010-09-05 Thread Jagdeep Singh Malhi
> > I tried this, its not working. > > Sorry, but "not working" does not constitute useful information. > > My car isn't working. Can you fix it? ;-) model.py from django.db import models from django.forms import ModelForm class Input(models.Model): input1 = models.FloatField() input2 =

Re: Django template : For Loop

2010-09-05 Thread Steve Holden
On 9/5/2010 12:29 PM, Jagdeep Singh Malhi wrote: > >> If these objects are lists, say list1 and list2, in your view just >> create a single object made up of pairs of elements from the original lists: >> >>values = zip(list1, list2) >> >> Then you can pass that item to your template and iterat

Re: Django template : For Loop

2010-09-05 Thread Justin Myers
What error message is it giving you? I'd assume it's a problem with the objects you're passing it, since zip is a built-in Python function: http://docs.python.org/library/functions.html#zip On Sep 5, 11:29 am, Jagdeep Singh Malhi wrote: > > If these objects are lists, say list1 and list2, in yo

Re: Django template : For Loop

2010-09-05 Thread Jagdeep Singh Malhi
> If these objects are lists, say list1 and list2, in your view just > create a single object made up of pairs of elements from the original lists: > >    values = zip(list1, list2) > > Then you can pass that item to your template and iterate over it. I tried this, its not working. -- You recei

Re: Django template : For Loop

2010-09-05 Thread Steve Holden
On 9/5/2010 7:54 AM, Jagdeep Singh Malhi wrote: >> I have question about "for loop" used in Templates the correct >> Syntax of using For Loop in template is : {% for X in VALUE %} >> >> but I want to use For loop with two value Is it possible to use two >> value in one loop? For example : {% for X

Django template : For Loop

2010-09-05 Thread Jagdeep Singh Malhi
I have question about "for loop" used in Templates the correct Syntax of using For Loop in template is : {% for X in VALUE %} but I want to use For loop with two value Is it possible to use two value in one loop? For example : {% for X, Y in VALUE1, VALUE2 %} Or {% for X in VALUE1 && Y in VAL

Re: Another question: how to apply custom variable into django template automatically?

2010-08-17 Thread Steve Holden
s > very boring... > > So is there some method to implement applying custom variable into > django template automatically? I find some materials, may be > RequestContext can handle it, but I don't know how to insert my custom > variable into it? > > Anyone can help? > &g

Re: Another question: how to apply custom variable into django template automatically?

2010-08-17 Thread Daniel Roseman
y boring... > > So is there some method to implement applying custom variable into > django template automatically? I find some materials, may be > RequestContext can handle it, but I don't know how to insert my custom > variable into it? > > Anyone can he

Another question: how to apply custom variable into django template automatically?

2010-08-17 Thread Tang Daogang
variable into django template automatically? I find some materials, may be RequestContext can handle it, but I don't know how to insert my custom variable into it? Anyone can help? Thank you! -- You received this message because you are subscribed to the Google Groups "Django users" gr

Re: Django template compilation

2010-08-13 Thread Russell Keith-Magee
On Sat, Aug 14, 2010 at 7:40 AM, Antoni Aloy wrote: > Hello! > > Today I have been benchmarking a Django template to PHP compilar > called Haanga http://github.com/crodas/Haanga/ a development sponsored > by meneame.net a Digg like spanish site. Ricardo has made some sort of &

Django template compilation

2010-08-13 Thread Antoni Aloy
Hello! Today I have been benchmarking a Django template to PHP compilar called Haanga http://github.com/crodas/Haanga/ a development sponsored by meneame.net a Digg like spanish site. Ricardo has made some sort of benchmark http://gallir.wordpress.com/2010/08/13/haanga-vs-django-vs-h2o. With my

Re: how to create a custom django template filter(please help)

2010-07-26 Thread Joseph
hi all thanks for answering my question i already found the answer just dont do this it will work {% load customTags %} tks Joseph On Jul 27, 8:59 am, Joseph wrote: > thanks , but still doesnt work.. > > On Jul 27, 8:48 am, Karen Tracey wrote: > > > > > On Mon, Jul 26, 2010 at 9:18 PM, Joseph

Re: how to create a custom django template filter(please help)

2010-07-26 Thread Joseph
thanks , but still doesnt work.. On Jul 27, 8:48 am, Karen Tracey wrote: > On Mon, Jul 26, 2010 at 9:18 PM, Joseph wrote: > > hi > > the level of directory(named templateTags) is same with the model.py > > and main.py > > and i put both __init__.py customTags.py and under templateTags > > > for

Re: how to create a custom django template filter(please help)

2010-07-26 Thread Karen Tracey
On Mon, Jul 26, 2010 at 9:18 PM, Joseph wrote: > hi > the level of directory(named templateTags) is same with the model.py > and main.py > and i put both __init__.py customTags.py and under templateTags > > for sure the name __init__.py is correct > > i run on AppEngine not Django > > Try naming

Re: how to create a custom django template filter(please help)

2010-07-26 Thread Joseph
hi the level of directory(named templateTags) is same with the model.py and main.py and i put both __init__.py customTags.py and under templateTags for sure the name __init__.py is correct i run on AppEngine not Django would u tell me more detail about this and thanks answering my question tks

Re: how to create a custom django template filter(please help)

2010-07-26 Thread Daniel Roseman
On Jul 26, 1:56 pm, Joseph wrote: > hi > im a newbie if u know please answer me > i just follow steps of django   > websitehttp://www.djangoproject.com/documentation/0.96/templates_python/ > > create a directory under inside has two file _init_.py and > customTags.py > > content of customTags.py >

Re: how to create a custom django template filter(please help)

2010-07-26 Thread Bill Freeman
It's a bit hard to tell in the browser on this webmail account, but I think that you have the wrong number of underscores before and after "init" in "__init__.py". There must be two underscore characters before the word "init" and two after it, before the ".py". The tutorial at python.org really i

Re: how to create a custom django template filter(please help)

2010-07-26 Thread Steve Holden
On 7/26/2010 1:56 PM, Joseph wrote: > hi > im a newbie if u know please answer me > i just follow steps of django website > http://www.djangoproject.com/documentation/0.96/templates_python/ > > create a directory under inside has two file _init_.py and > customTags.py > > content of customTags.p

how to create a custom django template filter(please help)

2010-07-26 Thread Joseph
hi im a newbie if u know please answer me i just follow steps of django website http://www.djangoproject.com/documentation/0.96/templates_python/ create a directory under inside has two file _init_.py and customTags.py content of customTags.py from google.appengine.ext.webapp import template re

Re: what kind i acces from django template variable?

2010-07-19 Thread owidjaya
yes that is what i meant. can i sort the related objects in the template? instead of passing another variable from the views.py other than that what other built in variables can i access from the template? On Jul 19, 11:37 am, Venkatraman S wrote: > On Mon, Jul 19, 2010 at 11:06 PM, owidjaya wro

Re: what kind i acces from django template variable?

2010-07-19 Thread Venkatraman S
On Mon, Jul 19, 2010 at 11:06 PM, owidjaya wrote: > How can i find out what variable is accessible from the template? > You need to pass the result of the query to the template. Or did you mean accessing the 'related' objects from the passed objects to the template? -V -- You received this me

what kind i acces from django template variable?

2010-07-19 Thread owidjaya
Hi All, How can i find out what variable is accessible from the template? If I have 2 models Model A: Name = text Model B: Name = text a = ForeignKey(A) how can i order the list of "objectA.b_set.all" from the template? -- You received this message because you are subscribed to the Google

Re: django template variables

2010-07-11 Thread Syed Ali Saim
:) -- 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

Re: django template variables

2010-07-10 Thread commonzenpython
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

Re: django template variables

2010-07-10 Thread Syed Ali Saim
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

Re: django template variables

2010-07-10 Thread commonzenpython
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

Re: django template variables

2010-07-10 Thread Syed Ali Saim
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

django template variables

2010-07-10 Thread commonzenpython
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

Re: HTML Frames and Django Template include

2010-07-06 Thread thusjanthan
rote: > I would like to use html frames in Django but my initial experiements > with it have not worked out. > > * Is there anyway to combine HTML frames into a Django >   template {% include t? > > * I definitely need Django Context on the right side of the frame, >   t

HTML Frames and Django Template include

2010-07-06 Thread NoviceSortOf
I would like to use html frames in Django but my initial experiements with it have not worked out. * Is there anyway to combine HTML frames into a Django template {% include t? * I definitely need Django Context on the right side of the frame, the left side is strictly navigational and of

Re: How to manually render a Django template for an inlineformset_factory with can_delete = True / False

2010-04-15 Thread chefsmart
Makes sense. Thanks. On Apr 15, 7:03 pm, Tom Evans wrote: > On Thu, Apr 15, 2010 at 2:00 PM, chefsmart wrote: > > Thanks for that tip. > > > I can guess what empty_permitted is, but could you explain how > > empty_permitted is related to can_delete? I couldn't find it in the > > docs, and such r

Re: How to manually render a Django template for an inlineformset_factory with can_delete = True / False

2010-04-15 Thread Tom Evans
On Thu, Apr 15, 2010 at 2:00 PM, chefsmart wrote: > Thanks for that tip. > > I can guess what empty_permitted is, but could you explain how > empty_permitted is related to can_delete? I couldn't find it in the > docs, and such relationship is not apparent from the code. > > Regards. > empty_permi

Re: How to manually render a Django template for an inlineformset_factory with can_delete = True / False

2010-04-15 Thread chefsmart
Thanks for that tip. I can guess what empty_permitted is, but could you explain how empty_permitted is related to can_delete? I couldn't find it in the docs, and such relationship is not apparent from the code. Regards. On Apr 15, 3:16 pm, Tom Evans wrote: > On Thu, Apr 15, 2010 at 6:45 AM, che

Re: How to manually render a Django template for an inlineformset_factory with can_delete = True / False

2010-04-15 Thread Tom Evans
On Thu, Apr 15, 2010 at 6:45 AM, chefsmart wrote: > Hi, > > I have an inlineformset with a custom Modelform. So it looks something > like this: > > MyInlineFormSet = inlineformset_factory(MyMainModel, MyInlineModel, > form=MyCustomInlineModelForm) > > I am rendering this inlineformset manually in

How to manually render a Django template for an inlineformset_factory with can_delete = True / False

2010-04-14 Thread chefsmart
Hi, I have an inlineformset with a custom Modelform. So it looks something like this: MyInlineFormSet = inlineformset_factory(MyMainModel, MyInlineModel, form=MyCustomInlineModelForm) I am rendering this inlineformset manually in a template so that I have more control over widgets and javascript

Re: how to achieve the break tag in django template

2010-04-12 Thread David De La Harpe Golden
On 09/04/10 12:42, CCC wrote: now i have a finished template which wrote by j2ee,like this: Your template stuff (FreeMarker I think?), well, it is not Django. And Now i want to changeit,write by django,anyone know how to achieve the "<#break>" in this tenplate thanks! Well, you can't (IIRC

Re: how to achieve the break tag in django template

2010-04-12 Thread CCC
Thanks for reply I know waht's you mean. But in the template inside the for loop,there are some 'css',not only just put the result in the template That's the difficult i can't solved out On Apr 12, 4:41 pm, Jirka Vejrazka wrote: > >  the syntax you're u

Re: how to achieve the break tag in django template

2010-04-12 Thread Jirka Vejrazka
>  the syntax you're using is not standard Django template syntax, so > unless someone has replaced the default Django tempating system with > the same one as you did (and is familiar with it and read your email), > you are unlikely to get a response from this list. Oops - sorr

Re: how to achieve the break tag in django template

2010-04-12 Thread Jirka Vejrazka
>> now i have a finished template which wrote by j2ee,like this: >>         <#list  dailyStarList as dailyS> >>                > 0>class="list_color_w"<#else>class="list_color"><#list Hi, the syntax you're using is not

to achieve the break tag in django template,exit the for loop

2010-04-11 Thread CCC
which likes {% for a in as%} {% for b in bs%} {%if a.id == b.id%} some content and exist the for loop {% endif %} {% endfor %} {% endfor %} any one knows? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: how to achieve the break tag in django template

2010-04-11 Thread CCC
anyone can help?Thanks advance On Apr 9, 7:42 pm, CCC wrote: > now i have a finished template which wrote by j2ee,like this: >         <#list  dailyStarList as dailyS> >                 0>class="list_color_w"<#else>class="list_color"><#list > chatAvatarList as cal> >                              

how to achieve the break tag in django template

2010-04-09 Thread CCC
now i have a finished template which wrote by j2ee,like this: <#list dailyStarList as dailyS> class="list_color_w"<#else>class="list_color"><#list chatAvatarList as cal> <#if dailyS.avatarid == cal.id> $

Django Template Mode for Panic Coda and SubEthaEdit

2010-02-23 Thread jbergantine
For anyone else that combines Django with Coda, I've created a mode for the Django Template language. You can preview it and get more info from http://joebergantine.com/werkstatt/djangotemplate. -- You received this message because you are subscribed to the Google Groups "Django us

Re: django template blocks and jquery

2010-02-17 Thread bruno desthuilliers
On 17 fév, 20:39, Joel Stransky wrote: > Ok thanks. I never actually tried it, just assumed it wouldn't work. I'll > give it a shot next time I run into this. > FWIW, your current solution is IMHO way cleaner (=> more readable, more explicit, and less likely to break if / when something changes

Re: django template blocks and jquery

2010-02-17 Thread Joel Stransky
Ok thanks. I never actually tried it, just assumed it wouldn't work. I'll give it a shot next time I run into this. On Wed, Feb 17, 2010 at 3:49 AM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > > > On Feb 16, 10:50 pm, Joel Stransky wrote: > > That was my first thought too David

Re: django template blocks and jquery

2010-02-17 Thread bruno desthuilliers
On Feb 16, 10:50 pm, Joel Stransky wrote: > That was my first thought too David but the %} both closes the js method > declaration and causes a syntax error. It shouldn't - unless you try to display the unrendered template in your browser, of course. -- You received this message because you a

Re: django template blocks and jquery

2010-02-16 Thread Joel Stransky
That was my first thought too David but the %} both closes the js method declaration and causes a syntax error. Turns out however that you can have more than 1 domready function so I just enclosed the global ones in a new .js file and appended a completely new $(document).ready() function in the ch

Re: django template blocks and jquery

2010-02-16 Thread David Zhou
There are a couple of ways, but here's one off the top of my head: Base template: $(function(){ function1() { ... } function2() { ... } {% block additional_domready %}{% endblock %} }); {% block additional_js }%}{% endblock %} child template that extends base template: {% block add

django template blocks and jquery

2010-02-16 Thread Joel Stransky
Still very new to django so excuse the newbish questions. This might be obvious but I need a smart solution. I have a template that runs a jquery function at document ready which defines a few other functions. I only need a couple of these functions in the template I'm extending, the other I need

Re: Django Template System with no Django instalation

2010-02-11 Thread Matías Iturburu
ate language without django (you'll always end up with django as dependency). The better way is to use jinja (http://jinja.pocoo.org/2/) it has the same semantics, quite a lot of it's magic and it's standalone from the start up. Cheers > On Feb 11, 8:43 am, Gerson Goulart wrote: &

Re: Django Template System with no Django instalation

2010-02-11 Thread creecode
Hello Gerson, This might give you a starting point < http://docs.djangoproject.com/en/dev/ref/templates/api/#configuring-the-template-system-in-standalone-mode>. On Feb 11, 8:43 am, Gerson Goulart wrote: > Is it possible to have the Django Template System running straight > over Ap

Django Template System with no Django instalation

2010-02-11 Thread Gerson Goulart
Is it possible to have the Django Template System running straight over Apache without the need of the whole Django Framework instaled, let's say, to make it possible to use this template system with other systems made in other languages such Java, just using this TPL system process the outp

Re: Javascript argument and django template tags

2010-01-26 Thread Sam Lai
2010/1/27 mojito : > I'd like to do something as follows: > > > function namelist(name) { > . > > {% ifequal  myname name %} > > {% endifequal %} > > > If I hardcode name this works not otherwise,  please help. That doesn't work because

Javascript argument and django template tags

2010-01-26 Thread mojito
I'd like to do something as follows: function namelist(name) { . {% ifequal myname name %} {% endifequal %} If I hardcode name this works not otherwise, please help. Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post

Re: Convert Joomla Template to Django Template

2010-01-17 Thread esatterwh...@wi.rr.com
to code well.  So I ask > you more professional-minded people out there:  Is there an easy way > (or at least a not-so-difficult way) to convert my Joomla files I have > now in a .zip folder to a Django template? > > Any help would be greatly be appreciated.  And a short step-

Convert Joomla Template to Django Template

2010-01-16 Thread matt6486
. So I ask you more professional-minded people out there: Is there an easy way (or at least a not-so-difficult way) to convert my Joomla files I have now in a .zip folder to a Django template? Any help would be greatly be appreciated. And a short step-by-step explanation would be amazing! Than

Re: How to use French accent on django template?

2009-11-14 Thread Andy Mikhailenko
repared by your view. Django will display excellent traceback and expose locals() from the view. You can also pass the data directly to template filters or tags to see the traceback. On 12 ноя, 21:24, NMarcu wrote: > Hello all, > >    How to use French accent on django template? It'

Re: How to use French accent on django template?

2009-11-13 Thread Karen Tracey
On Fri, Nov 13, 2009 at 4:54 AM, Nicu Marcu wrote: > Is not coming from database, Db is postgresql, and is set to utf-8, and is > accept words with accents. > > > If you post the traceback that goes with the error someone might be able to help. Karen -- You received this message because you ar

Re: How to use French accent on django template?

2009-11-13 Thread Nicu Marcu
Is not coming from database, Db is postgresql, and is set to utf-8, and is accept words with accents. 2009/11/12 Tom Evans > On Thu, Nov 12, 2009 at 4:30 PM, rebus_ wrote: > >> 2009/11/12 NMarcu : >> > Hello all, >> > >> > How to use French accent on

Re: How to use French accent on django template?

2009-11-12 Thread Tom Evans
On Thu, Nov 12, 2009 at 4:30 PM, rebus_ wrote: > 2009/11/12 NMarcu : > > Hello all, > > > > How to use French accent on django template? It's very strange. in > > one template is working very well, but in other(templatetag) not, I > > got this error: >

Re: How to use French accent on django template?

2009-11-12 Thread rebus_
2009/11/12 NMarcu : > Hello all, > >   How to use French accent on django template? It's very strange. in > one template is working very well, but in other(templatetag) not, I > got this error: > > TemplateSyntaxError at /operators/ajax > > Caught an exception whil

How to use French accent on django template?

2009-11-12 Thread NMarcu
Hello all, How to use French accent on django template? It's very strange. in one template is working very well, but in other(templatetag) not, I got this error: TemplateSyntaxError at /operators/ajax Caught an exception while rendering: 'ascii' codec can't encode

Re: django template tag truncatewords_html, detect whether it truncated or not

2009-09-24 Thread Brian McKeever
I think you'll have to write a custom template tag: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#parsing-until-another-block-tag-and-saving-contents On Sep 24, 10:56 am, J wrote: > Hello, > > How can I detect whether the template tag truncatewords_html has > truncated the htm

django template tag truncatewords_html, detect whether it truncated or not

2009-09-24 Thread J
Hello, How can I detect whether the template tag truncatewords_html has truncated the html text or not? My current template code is as follows: {{ object.body|truncatewords_html:100|removetags:"span"|safe }} {% trans "Read the rest" %} » However, I only want to dis

Re: equivalent of getattr in a django template

2009-09-23 Thread Chris Withers
Daniel Roseman wrote: > It's an intentional limitation of the template language that you can't > do that. You'll need to write a custom tag or filter - luckily it can > be done very trivially as a filter: > > @register.filter > def get_attr(obj, val) > return getattr(obj, val) > > Now in the

Re: equivalent of getattr in a django template

2009-09-23 Thread Karen Tracey
On Wed, Sep 23, 2009 at 1:05 PM, Chris Withers wrote: > > Hi All, > > I have this view function: > > def index(request,model,pk=None): > > return list_detail.object_list( > request, > queryset=model.objects.all(), > paginate_by=10, > template_name='index.html',

Re: equivalent of getattr in a django template

2009-09-23 Thread Daniel Roseman
On Sep 23, 6:05 pm, Chris Withers wrote: > Hi All, > > I have this view function: > > def index(request,model,pk=None): > >      return list_detail.object_list( >          request, >          queryset=model.objects.all(), >          paginate_by=10, >          template_name='index.html', >        

Re: equivalent of getattr in a django template

2009-09-23 Thread Chris Withers
Maksymus007 wrote: > {{object.name}} ? no, that is the equivalent of: getattr(object,'name') I want: getattr(object,name) Subtle, but rather important, difference... Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -

Re: equivalent of getattr in a django template

2009-09-23 Thread Maksymus007
On Wed, Sep 23, 2009 at 7:05 PM, Chris Withers wrote: > > Hi All, > > I have this view function: > > def index(request,model,pk=None): > >     return list_detail.object_list( >         request, >         queryset=model.objects.all(), >         paginate_by=10, >         template_name='index.html',

equivalent of getattr in a django template

2009-09-23 Thread Chris Withers
Hi All, I have this view function: def index(request,model,pk=None): return list_detail.object_list( request, queryset=model.objects.all(), paginate_by=10, template_name='index.html', extra_context=dict( column_titles = [f.name for

Django template include context

2009-09-11 Thread jaap
I'm using django 1.0's templates on GAE. I've got a for loop that outputs elements. I update their contents using ajax. I want to reuse the part of the template that renders the content of these elements. I have two handlers that handle /stufflist and /stuff/? reload=ajax. The first handler pa

Re: django template language issue

2009-08-17 Thread Adonis
Thanks! On Aug 17, 11:53 am, David Zhou wrote: > On Mon, Aug 17, 2009 at 6:39 AM, Adonis wrote: > > My problem is that even if the 'projects' queryset is empty, it still > > includes the projects.html > > Is there another way to do it? > > If you're using at least Django 1.1, you can use the emp

Re: django template language issue

2009-08-17 Thread David Zhou
On Mon, Aug 17, 2009 at 6:39 AM, Adonis wrote: > My problem is that even if the 'projects' queryset is empty, it still > includes the projects.html > Is there another way to do it? If you're using at least Django 1.1, you can use the empty tag: http://docs.djangoproject.com/en/dev/ref/templates

Re: django template language issue

2009-08-17 Thread James Bennett
On Mon, Aug 17, 2009 at 5:39 AM, Adonis wrote: > My problem is that even if the 'projects' queryset is empty, it still > includes the projects.html > Is there another way to do it? Consult the documentation: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for-empty -- "Bureaucrat

django template language issue

2009-08-17 Thread Adonis
Hi all, I am doing this {% for item in projects %} {% include projects.html %} {% endfor %} My problem is that even if the 'projects' queryset is empty, it still includes the projects.html Is there another way to do it? Regards, --~--~-~--~~~---~--~~ You r

Re: getting current page URL in a Django Template

2009-08-06 Thread Daniel Roseman
On Aug 6, 9:33 pm, NealWalters wrote: > Is there a keyword that will automatically put the URL of the current > page in the Django form? > Or do I have to do that in code and pass it to the form as a normal > user variable? > > Here's what I'm trying to accomplish. I have a feedback form on a bas

getting current page URL in a Django Template

2009-08-06 Thread NealWalters
Is there a keyword that will automatically put the URL of the current page in the Django form? Or do I have to do that in code and pass it to the form as a normal user variable? Here's what I'm trying to accomplish. I have a feedback form on a base template. When the user clicks the feedback but

Re: Tastiest show-off Django template filters

2009-06-09 Thread Nicolas R
So what do these filters (humanise, typogrify) do? I would suggest a truncatesentences, to go along with truncatewords Daniele Procida wrote: > I'm doing a demo of some of our Django work soon. Partly, it'll be a > showcase for Django. One thing I'd like to do is demonstrate Django's > template

Tastiest show-off Django template filters

2009-06-02 Thread Daniele Procida
I'm doing a demo of some of our Django work soon. Partly, it'll be a showcase for Django. One thing I'd like to do is demonstrate Django's template filters, to show how powerful it is and how it can make a a contribution to the quality of web output. So far I have: * typogrify * humanize Are th

For loop over integers rather than list within Django template

2009-04-17 Thread Martin Brochhaus
A while ago I needed a loop like "for(int i=0; i<20; i++)" within a Django template. Since the builtin for-loop only iterates over lists and since there was no appropriate template filter, I created a custom one. To me it seems as if this technique isn't well known to many us

Re: How can I filter query sets in a django template?

2009-04-08 Thread codecowboy
Thank you Daniel and Florian (Merci beaucoup. Je parle francais un petit). I think that I will be able to use both templates and custom model methods to accomplish what I am trying. On Apr 5, 4:18 pm, Daniel Roseman wrote: > On Apr 5, 8:49 pm, codecowboy wrote: > > > > > I posted a question

Re: Django Template Question

2009-04-06 Thread Briel
If you are trying to construct a "base" template for several views you could also use the {% if %} tags, and only show the relevant parts of the page. For example, if you wanted to display a table, but the number om columns would vary, this would enable you to only display the needed columns. On

Re: Django Template Question

2009-04-06 Thread Daniel Roseman
On Apr 6, 6:38 am, codingJoe wrote: > Up front, I'm not the most elegant coder, so please forgive. > >   I have a page that is produced using django templates.   I used the > templates to do the header and footer, but now I'm down into the body > of the page.   Using the data from my template, I

Django Template Question

2009-04-05 Thread codingJoe
Up front, I'm not the most elegant coder, so please forgive. I have a page that is produced using django templates. I used the templates to do the header and footer, but now I'm down into the body of the page. Using the data from my template, I am able to fill the first cell. Is is possibl

Re: How can I filter query sets in a django template?

2009-04-05 Thread Daniel Roseman
On Apr 5, 8:49 pm, codecowboy wrote: > I posted a question earlier today about circular imports (http:// > groups.google.com/group/django-users/t/6119e979131c8c25).  I now have > a follow question to that.  I've got the following view logic. > > def portal(request): >     scientist_id = 1 >     s

Re: How can I filter query sets in a django template?

2009-04-05 Thread Florian Strzelecki
Did you try to look at Inclusion Tag ? http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags In template you are not allowed to use some python code... but with an inclusion tag, you will be able to write this : {% load related_conferences %} {% related_conferences scien

How can I filter query sets in a django template?

2009-04-05 Thread codecowboy
I posted a question earlier today about circular imports (http:// groups.google.com/group/django-users/t/6119e979131c8c25). I now have a follow question to that. I've got the following view logic. def portal(request): scientist_id = 1 s = get_object_or_404(Scientist, pk=scientist_id)

Re: Django Template - i18n & filters and inner variables ?

2009-02-24 Thread MartinBorthiry
> > 1/ Using the i18n internationalization module, I would like to combine > > the translation with pluralize and capfirst filters. I know I’m a > > crazy dog. > > > {% trans 'tag' %}{{ tag_list|pluralize }} > > => All right, everything is ok. > > > But now, how can I specify the capfirst facili

Re: Django Template - i18n & filters and inner variables ?

2009-02-24 Thread Daniel Roseman
On Feb 24, 1:19 pm, Brogno wrote: > Dear djangonauts, > > I’m a newbie, a djangonoob ;) So, I have few little questions about > Django’s template system. Just for you information, I get Django 1.0.2 > > 1/ Using the i18n internationalization module, I would like to combine > the translation with

Django Template - i18n & filters and inner variables ?

2009-02-24 Thread Brogno
Dear djangonauts, I’m a newbie, a djangonoob ;) So, I have few little questions about Django’s template system. Just for you information, I get Django 1.0.2 1/ Using the i18n internationalization module, I would like to combine the translation with pluralize and capfirst filters. I know I’m a cr

Re: Django Template Hyphenated Keys

2009-02-17 Thread bfrederi
I decided to write a template tag for my purposes. It's kind of specific to a dictionary within a dictionary, but here is what I created: from django import template register = template.Library() def get_term_value(parser, token): try: # split_contents() knows not to split quoted st

Re: Django Template Hyphenated Keys

2009-02-17 Thread Daniel Roseman
On Feb 17, 2:01 pm, "euan.godd...@googlemail.com" wrote: > Why can't you change the dictionary? Can't you just create a copy of > the dict and rename the keys in your copy using _ rather than -  like > so: > > >>> bad = {'var-1':'Apples', 'var-2':'Pears'} > >>> good = dict() > >>> for k,v in bad.

Re: Django Template Hyphenated Keys

2009-02-17 Thread euan.godd...@googlemail.com
Why can't you change the dictionary? Can't you just create a copy of the dict and rename the keys in your copy using _ rather than - like so: >>> bad = {'var-1':'Apples', 'var-2':'Pears'} >>> good = dict() >>> for k,v in bad.items(): >>>good[k.replace('-','_')] = v >>> good {'var_1': 'Apples

Django Template Hyphenated Keys

2009-02-16 Thread bfrederi
I have a dictionary of dictionaries that I want to use in a template. Unfortunately some of the keys are hyphenated (I can't change it), so when I try to call them in the template using {{ dictionary.key- name }} it doesn't work: Could not parse the remainder: '-qualifiers' from 'display.vocabula

Re: django template language + greater than? does it exist?

2009-01-13 Thread Stratos
I don't think so, but you can do without it. Use {% ifequal %} and initialize your variable in your views. On Jan 12, 3:44 pm, rabbi wrote: > is there a greater than method in the template language? --~--~-~--~~~---~--~~ You received this message because you are

Re: django template language + greater than? does it exist?

2009-01-13 Thread Matías Costa
Advice: Think twice before adding comparisons in the templates. Conditions and all Bussines Rules(tm) *must* be in the model or the view. Time shows this advice punching your face. On Tue, Jan 13, 2009 at 12:54 PM, Mengsong Chen wrote: > FYI, > > http://www.djangosnippets.org/snippets/12/ > > O

<    1   2   3   4   5   6   >