Re: How to format datetime stamp in JS like it is doing by the date template tag?

2024-03-21 Thread the.one.abo...@gmail.com
Hello, thanks for your reply! 

The DATETIME_FORMAT setting of Django uses format strings that are 
incompatible with JS. E.g the default DATETIME_FORMAT value in Django is 'N 
j, Y'. 

You can check the allowed format strings in Django documentation 

.

- 
Gagan Deep
On Thursday, March 21, 2024 at 7:28:29 PM UTC+5:30 Matthias Yeni wrote:

> To format the timestamp in JavaScript according to the format defined by 
> Django, you can use Django settings to determine the format and adapt it in 
> JavaScript. Here's how you can do it:
>
>  
>
> Retrieve the date and time format defined by Django in your JavaScript 
> file using a Django template rendering method.
>
>  
>
>  
>
> 
>
>   // Get the date and time format defined by Django
>
>   var dateTimeFormat = "{{ DATETIME_FORMAT }}";
>
> 
>
>  
>
> Use the Moment.js JavaScript library to format the timestamp based on the 
> format retrieved.
>
>  
>
> https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js
> ">
>
> 
>
>   // Convert current date and time using Moment.js
>
>   var currentDateTime = moment();
>
>  
>
>   // Format date and time using format retrieved from Django
>
>   var formattedDateTime = currentDateTime.format(dateTimeFormat);
>
>  
>
>   // Use the formattedDateTime variable wherever you want to display the 
> timestamp in your page  console.log("Horodatage formaté :", 
> formattedDateTime);
>
> 
>
>  
>
> With this approach, your JavaScript code will automatically adapt to the 
> date and time format set by Django based on the LANGUAGE_CODE, USE_I18N, 
> and USE_L10N parameters, without needing to hardcode the formatting of the 
> datetime string into your JavaScript code.
>
> Le jeu. 21 mars 2024 à 12:13, the.one.abo...@gmail.com <
> the.one.abo...@gmail.com> a écrit :
>
>> Hello, 
>>
>> I have customizing Django admin by adding a datetime stamp to the page 
>> using JavaScript. I want to format the datetime stamp according to the 
>> format set by Django. 
>>
>> It is possible to get the DATETIME_FORMAT using the get_format() method 
>> in JS. But, this format is not supported by the Date().srftime method. 
>>
>> I don't want to hard-code the formatting of the datetime string. I want 
>> the code to adapt according to the Django settings for LANGUAGE_CODE, 
>> USE_I18N, and USE_L10N settings.
>>
>> TIA! 
>>
>> Regards,
>> Gagan Deep
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/cab2283d-c0dd-40d2-a82e-6a5dce675038n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1658b2b6-7773-4b25-a3cd-8391eb6c690cn%40googlegroups.com.


Re: How to format datetime stamp in JS like it is doing by the date template tag?

2024-03-21 Thread Matthias Yeni
To format the timestamp in JavaScript according to the format defined by
Django, you can use Django settings to determine the format and adapt it in
JavaScript. Here's how you can do it:



Retrieve the date and time format defined by Django in your JavaScript file
using a Django template rendering method.







  // Get the date and time format defined by Django

  var dateTimeFormat = "{{ DATETIME_FORMAT }}";





Use the Moment.js JavaScript library to format the timestamp based on the
format retrieved.



https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js
">



  // Convert current date and time using Moment.js

  var currentDateTime = moment();



  // Format date and time using format retrieved from Django

  var formattedDateTime = currentDateTime.format(dateTimeFormat);



  // Use the formattedDateTime variable wherever you want to display the
timestamp in your page  console.log("Horodatage formaté :",
formattedDateTime);





With this approach, your JavaScript code will automatically adapt to the
date and time format set by Django based on the LANGUAGE_CODE, USE_I18N,
and USE_L10N parameters, without needing to hardcode the formatting of the
datetime string into your JavaScript code.

Le jeu. 21 mars 2024 à 12:13, the.one.abo...@gmail.com <
the.one.above.all.ti...@gmail.com> a écrit :

> Hello,
>
> I have customizing Django admin by adding a datetime stamp to the page
> using JavaScript. I want to format the datetime stamp according to the
> format set by Django.
>
> It is possible to get the DATETIME_FORMAT using the get_format() method in
> JS. But, this format is not supported by the Date().srftime method.
>
> I don't want to hard-code the formatting of the datetime string. I want
> the code to adapt according to the Django settings for LANGUAGE_CODE,
> USE_I18N, and USE_L10N settings.
>
> TIA!
>
> Regards,
> Gagan Deep
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cab2283d-c0dd-40d2-a82e-6a5dce675038n%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACdfSiJaE3t9k_h_bYOZViiKUD4Lo%2BvzcqX9y7ky_Cuv3hDHUA%40mail.gmail.com.


How to format datetime stamp in JS like it is done by the date template tag?

2024-03-21 Thread the.one.abo...@gmail.com
Hello everyone, 

I am customizing Django admin by adding a datetime stamp to the page using 
JavaScript. I want to format the datetime stamp according to the format set 
by Django. 

It is possible to get the DATETIME_FORMAT using the get_format() method in 
JS which is "'j M Y, P'". But, this format is not supported by the 
Date().strftime method. 

I don't want to hard-code the formatting of the datetime string. I want the 
code to adapt according to the Django settings for LANGUAGE_CODE, USE_I18N, 
and USE_L10N settings.

TIA! 

Regards,
Gagan Deep

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a2c25e48-71a5-4619-ada3-96d2554c9e91n%40googlegroups.com.


How to format datetime stamp in JS like it is doing by the date template tag?

2024-03-21 Thread the.one.abo...@gmail.com
Hello, 

I have customizing Django admin by adding a datetime stamp to the page 
using JavaScript. I want to format the datetime stamp according to the 
format set by Django. 

It is possible to get the DATETIME_FORMAT using the get_format() method in 
JS. But, this format is not supported by the Date().srftime method. 

I don't want to hard-code the formatting of the datetime string. I want the 
code to adapt according to the Django settings for LANGUAGE_CODE, USE_I18N, 
and USE_L10N settings.

TIA! 

Regards,
Gagan Deep

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cab2283d-c0dd-40d2-a82e-6a5dce675038n%40googlegroups.com.


Re: Use include template tag in another app template folder

2022-09-02 Thread Wazed Khan
My Bad

On Fri, Sep 2, 2022, 4:23 PM Wazed Khan  wrote:

> You can set custom template folder in you project directory
>
> From there you can use any template for any app
>
> Change template path from setting
> You can look into documentation.
>
> On Fri, Sep 2, 2022, 4:09 PM Abdul Qoyyuum Haji Abdul Kadir <
> abdul.qoyy...@gmail.com> wrote:
>
>> It would be problematic. Just copy and paste the template file from one
>> app into the other.
>>
>> Abdul Qoyyuum Bin Haji Abdul Kadir
>> about.me/qoyyuum
>>
>> On Fri, Sep 2, 2022, 5:22 PM mohamed khaled <
>> mohamed.khaled33...@gmail.com> wrote:
>>
>>> I have two apps each one has template folder I want to use *include 
>>> *template
>>> tag to get template from other app how can I handle that
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/91eeb0b2-304a-4fef-94b1-e407ef82fbfcn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/91eeb0b2-304a-4fef-94b1-e407ef82fbfcn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CANVqoJ_L04oFerwgjod3hTUgvOfoDUb2kW8mn%3Dt1pxvsC8swjQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CANVqoJ_L04oFerwgjod3hTUgvOfoDUb2kW8mn%3Dt1pxvsC8swjQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALWCTKj11DqTUZMXDp2bXfr5%3D_sEoTWxMD7%3DqKUXKC_VyptK_g%40mail.gmail.com.


Re: Use include template tag in another app template folder

2022-09-02 Thread Wazed Khan
You can set custom template folder in you project directory

>From there you can use any template for any app

Change template path from setting
You can look into documentation.

On Fri, Sep 2, 2022, 4:09 PM Abdul Qoyyuum Haji Abdul Kadir <
abdul.qoyy...@gmail.com> wrote:

> It would be problematic. Just copy and paste the template file from one
> app into the other.
>
> Abdul Qoyyuum Bin Haji Abdul Kadir
> about.me/qoyyuum
>
> On Fri, Sep 2, 2022, 5:22 PM mohamed khaled 
> wrote:
>
>> I have two apps each one has template folder I want to use *include *template
>> tag to get template from other app how can I handle that
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/91eeb0b2-304a-4fef-94b1-e407ef82fbfcn%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/91eeb0b2-304a-4fef-94b1-e407ef82fbfcn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANVqoJ_L04oFerwgjod3hTUgvOfoDUb2kW8mn%3Dt1pxvsC8swjQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANVqoJ_L04oFerwgjod3hTUgvOfoDUb2kW8mn%3Dt1pxvsC8swjQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALWCTKj0TMxt8vBmtncX3-FswzZ7T5J%2B5F6ofd5fjFngzQYoqw%40mail.gmail.com.


Re: Use include template tag in another app template folder

2022-09-02 Thread Abdul Qoyyuum Haji Abdul Kadir
It would be problematic. Just copy and paste the template file from one app
into the other.

Abdul Qoyyuum Bin Haji Abdul Kadir
about.me/qoyyuum

On Fri, Sep 2, 2022, 5:22 PM mohamed khaled 
wrote:

> I have two apps each one has template folder I want to use *include *template
> tag to get template from other app how can I handle that
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/91eeb0b2-304a-4fef-94b1-e407ef82fbfcn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/91eeb0b2-304a-4fef-94b1-e407ef82fbfcn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANVqoJ_L04oFerwgjod3hTUgvOfoDUb2kW8mn%3Dt1pxvsC8swjQ%40mail.gmail.com.


Use include template tag in another app template folder

2022-09-02 Thread mohamed khaled
I have two apps each one has template folder I want to use *include *template 
tag to get template from other app how can I handle that 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/91eeb0b2-304a-4fef-94b1-e407ef82fbfcn%40googlegroups.com.


Re: NoReverseMatch if "url" template tag not used with app_name

2020-07-15 Thread Franz Ulenaers
It seems you have specified an app_name in your post/urls.py :

*app_name='post'*


Have you different name='home' in your apps then you have to use the 
app_name to make it unique !!


Op dinsdag 14 juli 2020 22:08:22 UTC+2 schreef strang:
>
> I understand what you are trying to explain. 
>
> I have used name=“home” for home view. I’m using urls.py for my app(main 
> URLs.py to route me to my apps urls.py, app urls.py contains path(‘’, 
> HomeView.as_view(), name=‘home’) 
>
> But when I try to reference this url in templates ({% url ‘home’%})I get 
> NoReverseMatch error. 
>
> However if I use {% url ‘post:home’ %} it works 
>
> post is my app name

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e29b215-fa55-42fc-9fc6-0e9d9c2c4089o%40googlegroups.com.


NoReverseMatch if "url" template tag not used with app_name

2020-07-14 Thread strang
I understand what you are trying to explain.

I have used name=“home” for home view. I’m using urls.py for my app(main 
URLs.py to route me to my apps urls.py, app urls.py contains path(‘’, 
HomeView.as_view(), name=‘home’)

But when I try to reference this url in templates ({% url ‘home’%})I get 
NoReverseMatch error.

However if I use {% url ‘post:home’ %} it works

post is my app name

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21f80c94-2e63-4ce7-a2d6-8ef634565f9do%40googlegroups.com.


NoReverseMatch if "url" template tag not used with app_name

2020-07-14 Thread Exactly musty
You are using django url, so it should be the same name you gave your url in 
your URLs.py e.g path('',homeview.as_views, name='home-page') 

So if I want to call this url in my template I will use the django url which is 
{% url 'home-page' %}.

You will have to check your url and see if what you named it matched what you 
wrote in your django template 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b4937809-5dc7-47e0-bc4e-77b9d15628a6o%40googlegroups.com.


NoReverseMatch if "url" template tag not used with app_name

2020-07-14 Thread strang

I just want to confirm if there has been a change in Django3.x

In Django2.x i could write something like
**
where 'home' is a url pattern in one of my apps(not the main url file)

But I get NoReverseMatch when I use the same in Django3
I have to use this convention
**

Which one is correct, for Django3.x?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e9c3c66d-3c47-4325-9e5b-0a9d5ff531fdn%40googlegroups.com.


Django does not Override Settings in Template Tag Testing

2019-12-11 Thread Eray Erdin
I have actually provided quite much verbose information in Stackoverflow 
<https://stackoverflow.com/questions/59251954/django-does-not-override-settings-in-template-tag-testing>.
 
I have a problem overriding settings as testing template tags. I leave this 
here in case you are interested.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8fa4ce5c-cdd1-4c1c-a00d-97554cf86633%40googlegroups.com.


Re: template tag help please?

2018-08-26 Thread Tosin Ayoola
good day guys I'm working on a project but currently I'm having
issues, which is I created a model to save some images files & I
created a template to display the images but the issue now is for loop
isn't displaying the files at the template

On 8/23/18, Tosin Ayoola  wrote:
> this is the link https://github.com/olaneat/ask_the_schools will rili b
> glad if u can help
>
>
> On Thu, Aug 23, 2018 at 2:31 PM Tosin Ayoola 
> wrote:
>
>> i have the code on git actually because i'm trying to get the add a file
>> at the admin page but i'm getting the error
>>
>>
>> On Thu, Aug 23, 2018 at 2:17 PM ireoluwa fakeye 
>> wrote:
>>
>>> Sorry didn't look at it well ,can I see a screen shot of your code
>>>
>>> On Thu, 23 Aug 2018, 14:10 Tosin Ayoola,  wrote:
>>>
 not properly routing my urls as in, i don't understand

 On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye 
 wrote:

> You Are not properly routing your  urls
>
> On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, 
> wrote:
>
>> good day please i'm having issues, attached below is one of the error
>> i'm getting also ive been trying to add bootstrap glyphicon to my
>> project
>> but it just display the text without the glyphicon,
>>
>> On Fri, Aug 17, 2018 at 12:54 PM MikeKJ 
>> wrote:
>>
>>> I want to pass 2 variables to a templatetag from within a template,
>>> a
>>> name and a date (eg, John 29/09/2018) to output the result of the
>>> templatetag def.
>>>
>>> The reason I want to do this is:
>>>
>>> From a list of all names:
>>>
>>> The name comes from a model that has a foreign key to another model
>>> that has actions performed by that name by date and I want to output
>>> the
>>> action taken on that date so something like:
>>>
>>> from django import template
>>> from django.conf import settings
>>> from django.utils.html import escape
>>> from user.models import person
>>> from action.models import data
>>>
>>> def (get_action):
>>> action = Data.objects.get.filter(person=name).filter(date=date)
>>> return action
>>>
>>> but how do I pass the variables in the 1st place please?
>>>
>>>
>>> --
>>> 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 this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
 --
 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 this group, send em

Re: template tag help please?

2018-08-23 Thread Tosin Ayoola
this is the link https://github.com/olaneat/ask_the_schools will rili b
glad if u can help


On Thu, Aug 23, 2018 at 2:31 PM Tosin Ayoola  wrote:

> i have the code on git actually because i'm trying to get the add a file
> at the admin page but i'm getting the error
>
>
> On Thu, Aug 23, 2018 at 2:17 PM ireoluwa fakeye  wrote:
>
>> Sorry didn't look at it well ,can I see a screen shot of your code
>>
>> On Thu, 23 Aug 2018, 14:10 Tosin Ayoola,  wrote:
>>
>>> not properly routing my urls as in, i don't understand
>>>
>>> On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye 
>>> wrote:
>>>
 You Are not properly routing your  urls

 On Thu, 23 Aug 2018, 14:03 Tosin Ayoola, 
 wrote:

> good day please i'm having issues, attached below is one of the error
> i'm getting also ive been trying to add bootstrap glyphicon to my project
> but it just display the text without the glyphicon,
>
> On Fri, Aug 17, 2018 at 12:54 PM MikeKJ 
> wrote:
>
>> I want to pass 2 variables to a templatetag from within a template, a
>> name and a date (eg, John 29/09/2018) to output the result of the
>> templatetag def.
>>
>> The reason I want to do this is:
>>
>> From a list of all names:
>>
>> The name comes from a model that has a foreign key to another model
>> that has actions performed by that name by date and I want to output the
>> action taken on that date so something like:
>>
>> from django import template
>> from django.conf import settings
>> from django.utils.html import escape
>> from user.models import person
>> from action.models import data
>>
>> def (get_action):
>> action = Data.objects.get.filter(person=name).filter(date=date)
>> return action
>>
>> but how do I pass the variables in the 1st place please?
>>
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
 --
 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 this group, send email to django-users@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> 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 this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com
>>> 

Re: template tag help please?

2018-08-23 Thread Tosin Ayoola
i have the code on git actually because i'm trying to get the add a file at
the admin page but i'm getting the error


On Thu, Aug 23, 2018 at 2:17 PM ireoluwa fakeye  wrote:

> Sorry didn't look at it well ,can I see a screen shot of your code
>
> On Thu, 23 Aug 2018, 14:10 Tosin Ayoola,  wrote:
>
>> not properly routing my urls as in, i don't understand
>>
>> On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye 
>> wrote:
>>
>>> You Are not properly routing your  urls
>>>
>>> On Thu, 23 Aug 2018, 14:03 Tosin Ayoola,  wrote:
>>>
 good day please i'm having issues, attached below is one of the error
 i'm getting also ive been trying to add bootstrap glyphicon to my project
 but it just display the text without the glyphicon,

 On Fri, Aug 17, 2018 at 12:54 PM MikeKJ 
 wrote:

> I want to pass 2 variables to a templatetag from within a template, a
> name and a date (eg, John 29/09/2018) to output the result of the
> templatetag def.
>
> The reason I want to do this is:
>
> From a list of all names:
>
> The name comes from a model that has a foreign key to another model
> that has actions performed by that name by date and I want to output the
> action taken on that date so something like:
>
> from django import template
> from django.conf import settings
> from django.utils.html import escape
> from user.models import person
> from action.models import data
>
> def (get_action):
> action = Data.objects.get.filter(person=name).filter(date=date)
> return action
>
> but how do I pass the variables in the 1st place please?
>
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
 --
 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 this group, send email to django-users@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> 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 this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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

Re: template tag help please?

2018-08-23 Thread ireoluwa fakeye
Sorry didn't look at it well ,can I see a screen shot of your code

On Thu, 23 Aug 2018, 14:10 Tosin Ayoola,  wrote:

> not properly routing my urls as in, i don't understand
>
> On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye  wrote:
>
>> You Are not properly routing your  urls
>>
>> On Thu, 23 Aug 2018, 14:03 Tosin Ayoola,  wrote:
>>
>>> good day please i'm having issues, attached below is one of the error
>>> i'm getting also ive been trying to add bootstrap glyphicon to my project
>>> but it just display the text without the glyphicon,
>>>
>>> On Fri, Aug 17, 2018 at 12:54 PM MikeKJ  wrote:
>>>
 I want to pass 2 variables to a templatetag from within a template, a
 name and a date (eg, John 29/09/2018) to output the result of the
 templatetag def.

 The reason I want to do this is:

 From a list of all names:

 The name comes from a model that has a foreign key to another model
 that has actions performed by that name by date and I want to output the
 action taken on that date so something like:

 from django import template
 from django.conf import settings
 from django.utils.html import escape
 from user.models import person
 from action.models import data

 def (get_action):
 action = Data.objects.get.filter(person=name).filter(date=date)
 return action

 but how do I pass the variables in the 1st place please?


 --
 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 this group, send email to django-users@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> 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 this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-use

Re: template tag help please?

2018-08-23 Thread Tosin Ayoola
not properly routing my urls as in, i don't understand

On Thu, Aug 23, 2018 at 2:06 PM ireoluwa fakeye  wrote:

> You Are not properly routing your  urls
>
> On Thu, 23 Aug 2018, 14:03 Tosin Ayoola,  wrote:
>
>> good day please i'm having issues, attached below is one of the error i'm
>> getting also ive been trying to add bootstrap glyphicon to my project but
>> it just display the text without the glyphicon,
>>
>> On Fri, Aug 17, 2018 at 12:54 PM MikeKJ  wrote:
>>
>>> I want to pass 2 variables to a templatetag from within a template, a
>>> name and a date (eg, John 29/09/2018) to output the result of the
>>> templatetag def.
>>>
>>> The reason I want to do this is:
>>>
>>> From a list of all names:
>>>
>>> The name comes from a model that has a foreign key to another model that
>>> has actions performed by that name by date and I want to output the action
>>> taken on that date so something like:
>>>
>>> from django import template
>>> from django.conf import settings
>>> from django.utils.html import escape
>>> from user.models import person
>>> from action.models import data
>>>
>>> def (get_action):
>>> action = Data.objects.get.filter(person=name).filter(date=date)
>>> return action
>>>
>>> but how do I pass the variables in the 1st place please?
>>>
>>>
>>> --
>>> 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 this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHLKn70NnEcJLNH5-8nnc%2B90TaTx3iqCiXuiVAdd6xop_teX7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-23 Thread ireoluwa fakeye
You Are not properly routing your  urls

On Thu, 23 Aug 2018, 14:03 Tosin Ayoola,  wrote:

> good day please i'm having issues, attached below is one of the error i'm
> getting also ive been trying to add bootstrap glyphicon to my project but
> it just display the text without the glyphicon,
>
> On Fri, Aug 17, 2018 at 12:54 PM MikeKJ  wrote:
>
>> I want to pass 2 variables to a templatetag from within a template, a
>> name and a date (eg, John 29/09/2018) to output the result of the
>> templatetag def.
>>
>> The reason I want to do this is:
>>
>> From a list of all names:
>>
>> The name comes from a model that has a foreign key to another model that
>> has actions performed by that name by date and I want to output the action
>> taken on that date so something like:
>>
>> from django import template
>> from django.conf import settings
>> from django.utils.html import escape
>> from user.models import person
>> from action.models import data
>>
>> def (get_action):
>> action = Data.objects.get.filter(person=name).filter(date=date)
>> return action
>>
>> but how do I pass the variables in the 1st place please?
>>
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHLKn714iMAzyE%3DaXn_tyJQos-xLWPrWS6BEfFq013%3DS-rmShA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO87g13Nmssbp_VPv6ktJmpRrSOasusm%2BvPnDhKGZe_o9yBZ%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: template tag help please?

2018-08-23 Thread Mike Jones
Andreas,  

Thank you for your help and patience I have got the damned thing working!!  

It helped that I remembered that one of the filter arguments was actually a 
foreign key in the model and had to be an integer id not a string,  that was 
being obfuscated by being a templatetag call.

 

Thank you

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andréas Kühne
Sent: 23 August 2018 08:15
To: django-users@googlegroups.com
Subject: Re: template tag help please?

 

Yes - but you still are doing it strange - you shouldn't use kwargs if you are 
sending the parameters and have the parameters in the function - use the 
parameters.

 

In other words: 

avn = kwargs['avn']

avd = kwargs['avd']

name = kwargs['name']

 

That is unnecessary




Regards,

 

Andréas

 

 

Den ons 22 aug. 2018 kl 16:55 skrev Mike Jones :

Ah I was just doing that to prove it was working

 

This is the actual tag

 

from django import template

from django.conf import settings

from django.utils.html import escape

from band.models import Data

 

register = template.Library()

 

@register.simple_tag

def do_cost( name, avn, avd, *args, **kwargs ):

avn = kwargs['avn']

avd = kwargs['avd']

name = kwargs['name']

val_set = Data.objects.filter(prop = name).filter(date_period=avd)

avn = 7  #this line is just for testing

if avn >= 7:

for x in val_set:

val = x.full

else:

for x in val_set:

val = x.short

return val

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andréas Kühne
Sent: 22 August 2018 15:20
To: django-users@googlegroups.com
Subject: Re: template tag help please?

 

Wait a secound, you are doing some very strange things

 

I didn't see this before.

 

You have defined the following:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
avn = kwargs['avn']
avd = kwargs['avd']
name = kwargs['name']
return name

 

The method has 3 parameters that you are sending to it - name, avn and avd. 
They correspond to the values sent to the method in order. So you don't need to 
use the kwargs dictionary - it's unnecessary...

You could just write:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
return name




Beacause you have sent the name to the method?

 

Regards,

 

Andréas

 

 

Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ :

Thank you Andreas Kuhne, progress

 

So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite 
happily but for some reason is now complaining 

 


Exception Type:

TemplateSyntaxError


 Exception Value:

Caught KeyError while rendering: 'avn'

 

Exception Location claims to beget_cost.py in do_cost, line 10  which is 
avn = kwargs['avn']

 

but the exception is in the template line {% load get_cost %}{% do_cost b.name 
avn avd %}

 

 

 

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com
 
<https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com?utm_medium=email&utm_source=footer>
 .
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com
 
<https://groups.google.com/d/msgid/django-users/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
 .
For more options, visit https://groups.google.com/d/optout.

-- 
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 this group, send email to dj

Re: template tag help please?

2018-08-23 Thread Andréas Kühne
Yes - but you still are doing it strange - you shouldn't use kwargs if you
are sending the parameters and have the parameters in the function - use
the parameters.

In other words:

avn = kwargs['avn']

avd = kwargs['avd']

name = kwargs['name']


That is unnecessary

Regards,

Andréas


Den ons 22 aug. 2018 kl 16:55 skrev Mike Jones :

> Ah I was just doing that to prove it was working
>
>
>
> This is the actual tag
>
>
>
> from django import template
>
> from django.conf import settings
>
> from django.utils.html import escape
>
> from band.models import Data
>
>
>
> register = template.Library()
>
>
>
> @register.simple_tag
>
> def do_cost( name, avn, avd, *args, **kwargs ):
>
> avn = kwargs['avn']
>
> avd = kwargs['avd']
>
> name = kwargs['name']
>
> val_set = Data.objects.filter(prop = name).filter(date_period=avd)
>
> avn = 7  #this line is just for testing
>
> if avn >= 7:
>
> for x in val_set:
>
> val = x.full
>
> else:
>
> for x in val_set:
>
> val = x.short
>
> return val
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Andréas Kühne
> *Sent:* 22 August 2018 15:20
> *To:* django-users@googlegroups.com
> *Subject:* Re: template tag help please?
>
>
>
> Wait a secound, you are doing some very strange things
>
>
>
> I didn't see this before.
>
>
>
> You have defined the following:
>
> @register.simple_tag
> def do_cost( name, avn, avd, *args, **kwargs ):
> avn = kwargs['avn']
> avd = kwargs['avd']
> name = kwargs['name']
> return name
>
>
>
> The method has 3 parameters that you are sending to it - name, avn and
> avd. They correspond to the values sent to the method in order. So you
> don't need to use the kwargs dictionary - it's unnecessary...
>
> You could just write:
>
> @register.simple_tag
> def do_cost( name, avn, avd, *args, **kwargs ):
> return name
>
>
> Beacause you have sent the name to the method?
>
>
>
> Regards,
>
>
>
> Andréas
>
>
>
>
>
> Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ :
>
> Thank you Andreas Kuhne, progress
>
>
>
> So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite
> happily but for some reason is now complaining
>
>
>
> *Exception Type:*
>
> TemplateSyntaxError
>
> * Exception Value:*
>
> Caught KeyError while rendering: 'avn'
>
>
>
> Exception Location claims to beget_cost.py in do_cost, line 10  which
> is avn = kwargs['avn']
>
>
>
> but the exception is in the template line {% load get_cost %}{% do_cost
> b.name avn avd %}
>
>
>
>
>
>
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Djang

Re: template tag help please?

2018-08-22 Thread Mikhailo Keda
Probably you don't need template tag at all, try {{ b.name }}
if you just need to get name value from b

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc0cedda-78ae-484b-837b-9eb990ab1d2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: template tag help please?

2018-08-22 Thread Mike Jones
Ah I was just doing that to prove it was working

 

This is the actual tag

 

from django import template

from django.conf import settings

from django.utils.html import escape

from band.models import Data

 

register = template.Library()

 

@register.simple_tag

def do_cost( name, avn, avd, *args, **kwargs ):

avn = kwargs['avn']

avd = kwargs['avd']

name = kwargs['name']

val_set = Data.objects.filter(prop = name).filter(date_period=avd)

avn = 7  #this line is just for testing

if avn >= 7:

for x in val_set:

val = x.full

else:

for x in val_set:

val = x.short

return val

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andréas Kühne
Sent: 22 August 2018 15:20
To: django-users@googlegroups.com
Subject: Re: template tag help please?

 

Wait a secound, you are doing some very strange things

 

I didn't see this before.

 

You have defined the following:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
avn = kwargs['avn']
avd = kwargs['avd']
name = kwargs['name']
return name

 

The method has 3 parameters that you are sending to it - name, avn and avd. 
They correspond to the values sent to the method in order. So you don't need to 
use the kwargs dictionary - it's unnecessary...

You could just write:

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
return name




Beacause you have sent the name to the method?

 

Regards,

 

Andréas

 

 

Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ :

Thank you Andreas Kuhne, progress

 

So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite 
happily but for some reason is now complaining 

 


Exception Type:

TemplateSyntaxError


 Exception Value:

Caught KeyError while rendering: 'avn'

 

Exception Location claims to beget_cost.py in do_cost, line 10  which is 
avn = kwargs['avn']

 

but the exception is in the template line {% load get_cost %}{% do_cost b.name 
avn avd %}

 

 

 

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com
 
<https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com?utm_medium=email&utm_source=footer>
 .
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com
 
<https://groups.google.com/d/msgid/django-users/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
 .
For more options, visit https://groups.google.com/d/optout.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5b7d7953.1c69fb81.85c08.097dSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-22 Thread Andréas Kühne
Wait a secound, you are doing some very strange things

I didn't see this before.

You have defined the following:
@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
avn = kwargs['avn']
avd = kwargs['avd']
name = kwargs['name']
return name

The method has 3 parameters that you are sending to it - name, avn and avd.
They correspond to the values sent to the method in order. So you don't
need to use the kwargs dictionary - it's unnecessary...

You could just write:
@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
return name

Beacause you have sent the name to the method?

Regards,

Andréas


Den ons 22 aug. 2018 kl 16:09 skrev MikeKJ :

> Thank you Andreas Kuhne, progress
>
>
> So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite
> happily but for some reason is now complaining
>
> Exception Type: TemplateSyntaxError
>  Exception Value:
>
> Caught KeyError while rendering: 'avn'
>
>
> Exception Location claims to beget_cost.py in do_cost, line 10  which
> is avn = kwargs['avn']
>
> but the exception is in the template line {% load get_cost %}{% do_cost
> b.name avn avd %}
>
>
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCcnJzyrWXGjTyF9NZAc0SE6zxQ1gbrd1ZM2Oc%2B3ZL_tyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-22 Thread MikeKJ
 

Thank you Andreas Kuhne, progress

 
So this {% load get_cost %}{% do_cost b.name avn avd %} was working quite 
happily but for some reason is now complaining 

Exception Type: TemplateSyntaxError 
 Exception Value: 

Caught KeyError while rendering: 'avn'


Exception Location claims to beget_cost.py in do_cost, line 10  which 
is avn = kwargs['avn']

but the exception is in the template line {% load get_cost %}{% do_cost 
b.name avn avd %}



-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d9d18dd-c8cb-494c-a2b8-8b06b64c40d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-22 Thread MikeKJ

Thank you Andreas Kuhne, progress

So this {% load get_cost %}{% do_cost b.name avn avd %} is not getting any 
error on the template but as simple as the below is there is no return

from django import template
from django.conf import settings
from django.utils.html import escape
register = template.Library()

@register.simple_tag
def do_cost( name, avn, avd, *args, **kwargs ):
avn = kwargs['avn']
avd = kwargs['avd']
name = kwargs['name']
return name


-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/76f303e0-84b4-4042-aad3-93e18bbfb863%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-22 Thread Andréas Kühne
Hi,

You don't need the {{}} when sending a variable to the template tag - try
removing them.

Regards,

Andréas


Den ons 22 aug. 2018 kl 12:17 skrev MikeKJ :

>
> I am so rusty I’m having trouble writing a simple_tag
>
>
>
> In the template
>
>
>
> {% for b in list %}
>
> {% load get_cost %}{% do_cost {{ b.name }} avn avd %}
>
>
>
> Also tried (per docs) {% do_cost name={{ b.name }} avn=avn avd=avd %}
>
> I definitely have values in the template passed from the view for avn and
> avd and of course b.name
>
>
>
> Tag
>
> from django import template
>
> from django.conf import settings
>
> from django.utils.html import escape
>
> from band.models import Data
>
>
>
> register = template.Library()
>
>
>
> @register.simple_tag
>
> def do_cost( name, avn, avd, *args, **kwargs ):
>
> avn = kwargs['avn']
>
> avd = kwargs['avd']
>
> name = kwargs['name']
>
>
>
> val = Data.objects.filter(property=name).filter(date_period=date)
>
> return val
>
>
>
> I just keep getting do_cost takes 3 arguments
>
> *** I know I want it to take 3 arguments***
>
> Is it telling me that I can’t use {{ b.name }} as an arg?
>
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/de8c0f7e-c8ee-4329-a954-457acfd01c64%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/de8c0f7e-c8ee-4329-a954-457acfd01c64%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCdcjnzhxoeLhpMsaSLbR0e7tHMtWp%2Bkczd9hyMr8e81_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-22 Thread MikeKJ


I am so rusty I’m having trouble writing a simple_tag

 

In the template

 

{% for b in list %}

{% load get_cost %}{% do_cost {{ b.name }} avn avd %}

 

Also tried (per docs) {% do_cost name={{ b.name }} avn=avn avd=avd %}

I definitely have values in the template passed from the view for avn and 
avd and of course b.name 

 

Tag

from django import template

from django.conf import settings

from django.utils.html import escape

from band.models import Data

 

register = template.Library()

 

@register.simple_tag

def do_cost( name, avn, avd, *args, **kwargs ):

avn = kwargs['avn']

avd = kwargs['avd']

name = kwargs['name']

 

val = Data.objects.filter(property=name).filter(date_period=date)

return val

 

I just keep getting do_cost takes 3 arguments

*** I know I want it to take 3 arguments***

Is it telling me that I can’t use {{ b.name }} as an arg?


-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/de8c0f7e-c8ee-4329-a954-457acfd01c64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-17 Thread Mikhailo Keda
"Then in the template any number of arguments, separated by spaces, may be 
passed to the template tag." from the Documentation

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39e03641-064f-416f-88a8-bf4198854924%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-17 Thread MikeKJ
 

Yes

 

For example, in the filter {{ var|foo:"bar" }}, the filter foo would be 
passed the variable var and the argument "bar".

 

I want to pass 2 (maybe 3) variables and correct me if I am wrong but 

Custom filters are just Python functions that take one or two arguments:

 

So could do  {{ var|foo:”bar, bar2” }}

or {{ var|foo:”bar” “bar2” }}   and pass 2 arguments?   The doc doesn’t 
specify 

 

I assume if 2 args

def cut(value, arg1, arg2):

 

?


-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e81d25fc-977c-47cd-84bf-ed65b2091391%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: template tag help please?

2018-08-17 Thread Mike Jones
Yes

 

For example, in the filter {{ var|foo:"bar" }}, the filter foo would be passed 
the variable var and the argument "bar".

 

I want to pass 2 (maybe 3) variables and correct me if I am wrong but 

Custom filters are just Python functions that take one or two arguments:

 

So could do  {{ var|foo:”bar, bar2” }}

or {{ var|foo:”bar” “bar2” }}   and pass 2 arguments?   The doc doesn’t specify 

 

I assume if 2 args

def cut(value, arg1, arg2):

 

?

 

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mikhailo Keda
Sent: 17 August 2018 14:43
To: Django users
Subject: Re: template tag help please?

 

Check the documentation - 
https://docs.djangoproject.com/ko/2.1/howto/custom-template-tags/

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/zG3S_9BQKMY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/553d2ac6-cac1-4b9a-b3bd-2a4f5934ae47%40googlegroups.com
 
<https://groups.google.com/d/msgid/django-users/553d2ac6-cac1-4b9a-b3bd-2a4f5934ae47%40googlegroups.com?utm_medium=email&utm_source=footer>
 .
For more options, visit https://groups.google.com/d/optout.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5b76d50e.1c69fb81.ad6af.0d3eSMTPIN_ADDED_BROKEN%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag help please?

2018-08-17 Thread Mikhailo Keda
Check the documentation 
- https://docs.djangoproject.com/ko/2.1/howto/custom-template-tags/

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/553d2ac6-cac1-4b9a-b3bd-2a4f5934ae47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


template tag help please?

2018-08-17 Thread MikeKJ
I want to pass 2 variables to a templatetag from within a template, a name 
and a date (eg, John 29/09/2018) to output the result of the templatetag 
def.

The reason I want to do this is:

>From a list of all names:

The name comes from a model that has a foreign key to another model that 
has actions performed by that name by date and I want to output the action 
taken on that date so something like:

from django import template
from django.conf import settings
from django.utils.html import escape
from user.models import person
from action.models import data

def (get_action):
action = Data.objects.get.filter(person=name).filter(date=date)
return action

but how do I pass the variables in the 1st place please?


-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d7b9f60-9f88-41c6-8fec-cf858d7e6574%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch when trying to use get_absolute_url with custom template tag

2017-03-30 Thread Will Holmes
Oh yeah i see.

Brilliant sorted it! Thanks for your help Melvyn.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a2b33ac-7424-4a24-9888-148c11db5d7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch when trying to use get_absolute_url with custom template tag

2017-03-29 Thread Melvyn Sopacua
On Wednesday 29 March 2017 09:16:17 Will Holmes wrote:

> url(r'^(?P\d+)$/', views.viewEvent, name='viewevent'),

name = viewevent

> def get_absolute_url(self):
> return reverse('cal:viewEvent', args=[str(self.id)],
> current_app='cal')

name = viewEvent

> Sorry about the load of code posted. Any chance anyone knows what
> might have caused this issue?

Do you see it now?
-- 
Melvyn Sopacua

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11853972.BX1BFau5sG%40devstation.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch when trying to use get_absolute_url with custom template tag

2017-03-29 Thread Will Holmes


I am making a calendar app which has a custom template tag that takes the 
python HTML template function and overlays objects from the Events model on 
the correct days. I am trying to get the displayed objects to have a link 
directly to an object detail/edit view and am trying to use 
get_absolute_url and to reverse render this view. This is necessary as the 
custom template tag doesn't load correctly if I try to hardcode {% url %} 
template 
tags into it for each event via a for loop. I have spent some hours looking 
through stack overflow questions with no luck and have even changed my 
reverse to the object ID rather than the title of the event. I am hoping 
this is just a small thing that I have overlooked but no sure.


view:

def home(request, month=None, year=None):
if month == None:
_date = datetime.now()
else:
_date = date(int(year), int(month), 1)
title = "%s, %s" % (_date.strftime("%B"), _date.strftime("%Y"))

return render(request, 'calendar.html', calendar(_date, title))


url:

app_name = 'cal'
urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^newevent/$', views.newEvent, name='newevent'),
url(r'^(?P\d+)$/', views.viewEvent, name='viewevent'),
url(r'^(?P\d+)/(?P\d+)$', views.home, name='another-month')]


HTML:


  {% load calendarify %}
  {% calendarify year month event_list %}



Template tag relevant function:

def formatday(self, day, weekday):
if day != 0:
cssid = self.cssclasses[weekday]
cssclass = "daybox"
if date.today() == date(self.year, self.month, day):
cssid += ' today'
if day in self.events:
cssid += ' filled'
body = ['']
for event in self.events[day]:
body.append('')
body.append('' % event.get_absolute_url())
body.append(esc(event.title))
body.append('')
body.append('')
return self.day_cell(
cssclass, cssid, '%d %s' % (
day, ''.join(body)))
return self.day_cell(
cssclass, cssid, '%d' 
% (day))
return self.day_cell('nodaybox', 'noday', ' ')


Model:

class Events(models.Model):
...

def get_absolute_url(self):
return reverse('cal:viewEvent', args=[str(self.id)], current_app='cal')


Sorry about the load of code posted. Any chance anyone knows what might 
have caused this issue?

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aae357a0-84a7-46bd-a93d-4aac61f352c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "trans" template tag using wrong language

2017-03-11 Thread Joan Perals
Hi Antonis,

I think I figured this out. I have English as fallback language (LANGUAGE_CODE 
= 'en') in the settings, but my source language is German, and this 
mismatch seems to have been the source of all the trouble. Providing German 
translations (even if the original strings are already in German) seems to 
solve the issue.

Thanks for your help in any case,

Joan

On Thursday, March 9, 2017 at 10:51:11 AM UTC+1, Antonis Christofides wrote:
>
> It's very unlikely that such a basic behaviour won't work, so probably you 
> are doing something wrong (and so's the stack overflow poster). I made 
> several related changes in an app yesterday and I had absolutely no problem 
> with {% trans %} (but I'm using 1.8).
>
> Do you have USE_I18N = True?
>
> If in the template you use
>
>   {% get_current_language as current_language %}
>   {{ current_language }}
>
> does it show the correct language?
>
> Antonis Christofideshttp://djangodeployment.com
>
> On 03/09/2017 11:25 AM, Joan Perals wrote:
>
> This post on StackOverflow seems to report the same behaviour: 
>
> http://stackoverflow.com/questions/10282074/how-to-set-default-language-in-django-for-templates
>
> It's quite old (almost 5 years), but remains unresolved.
> -- 
> 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...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/02a7eb4a-086f-4e76-a693-3ae5623db08e%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce0215f5-9972-453e-9b6c-37bdcf3e66e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "trans" template tag using wrong language

2017-03-11 Thread Joan Perals
Hi Antonis,

I think I figured this out. I have English as fallback language (LANGUAGE_CODE 
= 'en') in the settings, but my source language is German, and this 
mismatch seems to have been the source of all the trouble. Providing German 
translations (even if the original strings are already in German) seems to 
solve the issue.

Thanks for your help in any case,

Joan

On Thursday, March 9, 2017 at 10:51:11 AM UTC+1, Antonis Christofides wrote:
>
> It's very unlikely that such a basic behaviour won't work, so probably you 
> are doing something wrong (and so's the stack overflow poster). I made 
> several related changes in an app yesterday and I had absolutely no problem 
> with {% trans %} (but I'm using 1.8).
>
> Do you have USE_I18N = True?
>
> If in the template you use
>
>   {% get_current_language as current_language %}
>   {{ current_language }}
>
> does it show the correct language?
>
> Antonis Christofideshttp://djangodeployment.com
>
> On 03/09/2017 11:25 AM, Joan Perals wrote:
>
> This post on StackOverflow seems to report the same behaviour: 
>
> http://stackoverflow.com/questions/10282074/how-to-set-default-language-in-django-for-templates
>
> It's quite old (almost 5 years), but remains unresolved.
> -- 
> 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...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/02a7eb4a-086f-4e76-a693-3ae5623db08e%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ff6f6461-aaba-4935-a636-8ee70e096626%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "trans" template tag using wrong language

2017-03-09 Thread Antonis Christofides
It's very unlikely that such a basic behaviour won't work, so probably you are
doing something wrong (and so's the stack overflow poster). I made several
related changes in an app yesterday and I had absolutely no problem with {%
trans %} (but I'm using 1.8).

Do you have USE_I18N = True?

If in the template you use

  {% get_current_language as current_language %}
  {{ current_language }}

does it show the correct language?

Antonis Christofides
http://djangodeployment.com

On 03/09/2017 11:25 AM, Joan Perals wrote:
> This post on StackOverflow seems to report the same behaviour:
> http://stackoverflow.com/questions/10282074/how-to-set-default-language-in-django-for-templates
>
> It's quite old (almost 5 years), but remains unresolved.
> -- 
> 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 this group, send email to django-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/02a7eb4a-086f-4e76-a693-3ae5623db08e%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/31891f30-ceff-afef-3c86-97f1cc887a6e%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: "trans" template tag using wrong language

2017-03-09 Thread Joan Perals
This post on StackOverflow seems to report the same behaviour:
http://stackoverflow.com/questions/10282074/how-to-set-default-language-in-django-for-templates

It's quite old (almost 5 years), but remains unresolved.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/02a7eb4a-086f-4e76-a693-3ae5623db08e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


"trans" template tag using wrong language

2017-03-08 Thread Joan Perals
I have a site using Django 1.10 with German and English as available 
languages, where German is the source language. Dynamic content is 
translated with django-modeltranslation and for static strings I am using 
Django's built-in `trans` template tag.

I want Django to return the page in the visitor's preferred language. I 
have read how Django discovers language preference 
<https://docs.djangoproject.com/en/dev/topics/i18n/translation/#how-django-discovers-language-preference>
 
several times, and I think I have everything right. As I change my language 
settings in my browser, the value of the `LANGUAGE_CODE` variable when 
displayed in a template always changes accordingly, and also the dynamic 
content is always returned in the expected language by 
django-modeltranslation. The locale middleware is of course in place, and 
so are the *.po and *.mo files as well. The browser request headers also 
look fine. But *it's only the `trans` template tag that is not picking my 
browser's language preference*. Instead, *it seems to directly resort to 
the initial value of the `LANGUAGE_CODE` variable as it is originally set 
in the settings file, without going through the algorithm described in the 
link above*.

Is this known? Certainly not what I expected, and it took me a lot of 
effort to narrow down the issue.

Thanks in advance for your help,

Joan

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/40954b21-3fb9-4596-8f19-7261ed3e8172%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: extend Media in custom template tag

2017-02-22 Thread guettli
 I see replies. Now I am unsure what happened:

 - nobody read my question
 - someone read it, but did not understand it
 - someone read it, understood it, but had no solution.
 - ... other.

Just for the records, here the related StackOverflow question: 
http://stackoverflow.com/questions/41592766/django-include-media-css-js-in-class-based-views

Am Montag, 9. Mai 2016 10:25:49 UTC+2 schrieb guettli:
>
> I have a custom Django template tag which creates HTML.
>
>
> This HTML needs some JS and CSS.
>
>
> How can I extend the media list with my custom template tag?
>
>
>
>
>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8270faf5-27cf-4c75-af42-8e4be7ba70a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: extend Media in custom template tag

2017-02-22 Thread guettli
I see replies. Now I am unsure what happened:

 - nobody read my question
 - someone read it, but did not understand it
 - someone read it, understood it, but had no solution.
 - ... other.


Am Montag, 9. Mai 2016 10:25:49 UTC+2 schrieb guettli:
>
> I have a custom Django template tag which creates HTML.
>
>
> This HTML needs some JS and CSS.
>
>
> How can I extend the media list with my custom template tag?
>
>
>
>
>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3bb77b31-b24d-4da2-9f9f-06b14e2306d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Template Tag

2016-09-15 Thread 'Abraham Varricatt' via Django users
The idea of doing a POST request during template rendering seems weird. As 
others have mentioned - that's not the place for it. 

But perhaps you issue could be a matter of performing your POST operation 
on the client side, instead of the django server? In that case, it might be 
worth investigating if you could code in some JS inside your template so 
that when the client's browser loads it, the POST operation is called and 
changes are made appropriately on the site. 

Yours,
Abraham V.


On Saturday, 10 September 2016 23:15:28 UTC+5:30, Al Johri wrote:
>
> I'm experimenting with creating templates out of subtemplates. These 
> subtemplates can be either (a) simple text or (b) a hash representing a 
> sentence (i.e. {subject: "Dog", verb: "eat", object: "my {{var}}", tense: 
> "past"}). I would like to run the hashes through a realization engine which 
> would render as "Dog ate my homework" given a context dictionary of {var: 
> "homework"}. The realization engine is accessed via a REST API.
>
> Does that make sense?
>
> On Friday, September 2, 2016 at 1:38:39 AM UTC-4, Constantine Covtushenko 
> wrote:
>>
>> Hi All,
>> There is no valuable reason to do it in the template. And no matter how 
>> to ate using it, cause template should only present view model(s).
>>
>> But if you tell us your intention may be we can suggest a better place 
>> for such request?
>>
>> Regards,
>>
>> On Sep 2, 2016 6:03 AM, "Al Johri"  wrote:
>>
>>> Ludovic,
>>>
>>> I'm using the templates for a different purpose, not in a web framework 
>>> or view.
>>>
>>> Thanks,
>>>
>>> Al
>>>
>>> On Thursday, September 1, 2016 at 8:09:29 AM UTC-4, ludovic coues wrote:
>>>>
>>>> I wouldn't do it this way. 
>>>> Personally, I would make the POST request in the view function, put 
>>>> the return value in the context. The template isn't a good place to 
>>>> have logic. It should only take data and format them. 
>>>>
>>>> 2016-09-01 5:33 GMT+02:00 Al Johri : 
>>>> > Hi Django Users, 
>>>> > 
>>>> > I want to make a custom template tag where the tag's renderer needs 
>>>> to make 
>>>> > a POST request. 
>>>> > 
>>>> > 
>>>> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#writing-the-renderer
>>>>  
>>>> > 
>>>> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#thread-safety-considerations
>>>>  
>>>> > 
>>>> > Is it possible to render the nodes of a template in multiple threads? 
>>>> I 
>>>> > would ideally like those POST requests to happen at the same time. 
>>>> > 
>>>> > Does anyone know of some similar project? 
>>>> > 
>>>> > Thanks, 
>>>> > 
>>>> > Al 
>>>> > 
>>>> > -- 
>>>> > 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...@googlegroups.com. 
>>>> > To post to this group, send email to django...@googlegroups.com. 
>>>> > Visit this group at https://groups.google.com/group/django-users. 
>>>> > To view this discussion on the web visit 
>>>> > 
>>>> https://groups.google.com/d/msgid/django-users/84ccc6dc-ae1d-404c-9a05-1b72fc36a778%40googlegroups.com.
>>>>  
>>>>
>>>> > For more options, visit https://groups.google.com/d/optout. 
>>>>
>>>>
>>>>
>>>> -- 
>>>>
>>>> Cordialement, Coues Ludovic 
>>>> +336 148 743 42 
>>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/7eaa219b-ddee-4fa2-8ffb-37d04f168965%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/7eaa219b-ddee-4fa2-8ffb-37d04f168965%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/80de9c3d-5ca6-40ba-b521-9cb719a25f9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Template Tag

2016-09-10 Thread Al Johri
I'm experimenting with creating templates out of subtemplates. These 
subtemplates can be either (a) simple text or (b) a hash representing a 
sentence (i.e. {subject: "Dog", verb: "eat", object: "my {{var}}", tense: 
"past"}). I would like to run the hashes through a realization engine which 
would render as "Dog ate my homework" given a context dictionary of {var: 
"homework"}. The realization engine is accessed via a REST API.

Does that make sense?

On Friday, September 2, 2016 at 1:38:39 AM UTC-4, Constantine Covtushenko 
wrote:
>
> Hi All,
> There is no valuable reason to do it in the template. And no matter how to 
> ate using it, cause template should only present view model(s).
>
> But if you tell us your intention may be we can suggest a better place for 
> such request?
>
> Regards,
>
> On Sep 2, 2016 6:03 AM, "Al Johri" > 
> wrote:
>
>> Ludovic,
>>
>> I'm using the templates for a different purpose, not in a web framework 
>> or view.
>>
>> Thanks,
>>
>> Al
>>
>> On Thursday, September 1, 2016 at 8:09:29 AM UTC-4, ludovic coues wrote:
>>>
>>> I wouldn't do it this way. 
>>> Personally, I would make the POST request in the view function, put 
>>> the return value in the context. The template isn't a good place to 
>>> have logic. It should only take data and format them. 
>>>
>>> 2016-09-01 5:33 GMT+02:00 Al Johri : 
>>> > Hi Django Users, 
>>> > 
>>> > I want to make a custom template tag where the tag's renderer needs to 
>>> make 
>>> > a POST request. 
>>> > 
>>> > 
>>> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#writing-the-renderer
>>>  
>>> > 
>>> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#thread-safety-considerations
>>>  
>>> > 
>>> > Is it possible to render the nodes of a template in multiple threads? 
>>> I 
>>> > would ideally like those POST requests to happen at the same time. 
>>> > 
>>> > Does anyone know of some similar project? 
>>> > 
>>> > Thanks, 
>>> > 
>>> > Al 
>>> > 
>>> > -- 
>>> > 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...@googlegroups.com. 
>>> > To post to this group, send email to django...@googlegroups.com. 
>>> > Visit this group at https://groups.google.com/group/django-users. 
>>> > To view this discussion on the web visit 
>>> > 
>>> https://groups.google.com/d/msgid/django-users/84ccc6dc-ae1d-404c-9a05-1b72fc36a778%40googlegroups.com.
>>>  
>>>
>>> > For more options, visit https://groups.google.com/d/optout. 
>>>
>>>
>>>
>>> -- 
>>>
>>> Cordialement, Coues Ludovic 
>>> +336 148 743 42 
>>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/7eaa219b-ddee-4fa2-8ffb-37d04f168965%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/7eaa219b-ddee-4fa2-8ffb-37d04f168965%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2718aa6b-3f5c-4c38-843b-773d41d944e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Template Tag

2016-09-01 Thread Constantine Covtushenko
Hi All,
There is no valuable reason to do it in the template. And no matter how to
ate using it, cause template should only present view model(s).

But if you tell us your intention may be we can suggest a better place for
such request?

Regards,

On Sep 2, 2016 6:03 AM, "Al Johri"  wrote:

> Ludovic,
>
> I'm using the templates for a different purpose, not in a web framework or
> view.
>
> Thanks,
>
> Al
>
> On Thursday, September 1, 2016 at 8:09:29 AM UTC-4, ludovic coues wrote:
>>
>> I wouldn't do it this way.
>> Personally, I would make the POST request in the view function, put
>> the return value in the context. The template isn't a good place to
>> have logic. It should only take data and format them.
>>
>> 2016-09-01 5:33 GMT+02:00 Al Johri :
>> > Hi Django Users,
>> >
>> > I want to make a custom template tag where the tag's renderer needs to
>> make
>> > a POST request.
>> >
>> > https://docs.djangoproject.com/en/1.10/howto/custom-template
>> -tags/#writing-the-renderer
>> > https://docs.djangoproject.com/en/1.10/howto/custom-template
>> -tags/#thread-safety-considerations
>> >
>> > Is it possible to render the nodes of a template in multiple threads? I
>> > would ideally like those POST requests to happen at the same time.
>> >
>> > Does anyone know of some similar project?
>> >
>> > Thanks,
>> >
>> > Al
>> >
>> > --
>> > 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...@googlegroups.com.
>> > To post to this group, send email to django...@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msgid/django-users/84ccc6dc-ae1d
>> -404c-9a05-1b72fc36a778%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>>
>> Cordialement, Coues Ludovic
>> +336 148 743 42
>>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/7eaa219b-ddee-4fa2-8ffb-37d04f168965%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7eaa219b-ddee-4fa2-8ffb-37d04f168965%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boXxVGX4JT9o2%3DKrtBsFDVr%2BrY9ZVpfLruWED3NUcW58cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Template Tag

2016-09-01 Thread Al Johri
Ludovic,

I'm using the templates for a different purpose, not in a web framework or 
view.

Thanks,

Al

On Thursday, September 1, 2016 at 8:09:29 AM UTC-4, ludovic coues wrote:
>
> I wouldn't do it this way. 
> Personally, I would make the POST request in the view function, put 
> the return value in the context. The template isn't a good place to 
> have logic. It should only take data and format them. 
>
> 2016-09-01 5:33 GMT+02:00 Al Johri >: 
> > Hi Django Users, 
> > 
> > I want to make a custom template tag where the tag's renderer needs to 
> make 
> > a POST request. 
> > 
> > 
> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#writing-the-renderer
>  
> > 
> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#thread-safety-considerations
>  
> > 
> > Is it possible to render the nodes of a template in multiple threads? I 
> > would ideally like those POST requests to happen at the same time. 
> > 
> > Does anyone know of some similar project? 
> > 
> > Thanks, 
> > 
> > Al 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/84ccc6dc-ae1d-404c-9a05-1b72fc36a778%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7eaa219b-ddee-4fa2-8ffb-37d04f168965%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Template Tag

2016-09-01 Thread ludovic coues
I wouldn't do it this way.
Personally, I would make the POST request in the view function, put
the return value in the context. The template isn't a good place to
have logic. It should only take data and format them.

2016-09-01 5:33 GMT+02:00 Al Johri :
> Hi Django Users,
>
> I want to make a custom template tag where the tag's renderer needs to make
> a POST request.
>
> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#writing-the-renderer
> https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#thread-safety-considerations
>
> Is it possible to render the nodes of a template in multiple threads? I
> would ideally like those POST requests to happen at the same time.
>
> Does anyone know of some similar project?
>
> Thanks,
>
> Al
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/84ccc6dc-ae1d-404c-9a05-1b72fc36a778%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTb_9_0eEV3MQR7EqxQGAxK%2BcfNNCy%3Df3vf3%2B9DOZiohoA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Custom Template Tag

2016-09-01 Thread Al Johri
Hi Django Users,

I want to make a custom template tag where the tag's renderer needs to make 
a POST request.

https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#writing-the-renderer
https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#thread-safety-considerations

Is it possible to render the nodes of a template in multiple threads? I 
would ideally like those POST requests to happen at the same time.

Does anyone know of some similar project?

Thanks,

Al

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/84ccc6dc-ae1d-404c-9a05-1b72fc36a778%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag don't work ==

2016-06-09 Thread Ing. Jaime Sanchez
ok this is view.

def junior_pending_impacts(request, pk=None):
queryset_list = IgcNew.objects.all()
count_new = IgcNew.objects.filter(IGC_Status__contains='New').count()
# log.warning('%s' % count_new)
noregistro = overall_impact.objects.all()
# log.warning('%s' % overall_impact.igc_master)

if overall_impact.igc_master == IgcNew.pk:
valor = overall_impact.igc_master
log.warning('%s' % valor)

context = {
"title": "Pending Impacts.",
"count": count_new,
"object_list": queryset_list,
"overall": noregistro,
}
return render(request, "junior_pending_impacts.html", context)

this is template.

{% for obj in object_list %}

  var myVar = setInterval(myTimer, 1000);
  
  function myTimer() {
  var d = new Date();
  document.getElementById("demo").innerHTML = 
d.toLocaleTimeString();
  }
  
{% if obj.IGC_Status == 'New' %}

  
IGC ID: {{ obj.pk }}
  IGC 
Subject: {{ obj.subject|truncatechars:100 }}
  
  
  
Summary: {{ obj.summary|truncatechars:100 }}
Impact: {% for over in overall %}{% ifequal 
over.igc_master obj.id %}TEST{{ over.igc_master }}{{ over.impact }}{% 
endifequal %}{% endfor %}
Pimary Contact(s): 
{% for over in overall %}

{% with index=over.igc_master %}

test {{ index }}
{% if index == obj.pk %}
mal {{ index }}
{% else %}
OK {{ index }}
{% endif %}

{% endwith %}


{% ifequal obj.pk over.igc_master %}
  Test Jaime Sanchez
  {{ over.primary_contacts }}
{% endifequal %} 
{% endfor %}
NOC Technician: 
Status: 
Remaining Time: 
Preview
  

{% endif %}
{% endfor %}

El jueves, 9 de junio de 2016, 11:33:24 (UTC-5), Ing. Jaime Sanchez 
escribió:
>
> Help please!!
>
> I need do like this
> in django 1.9 template tag 
>
> {% if model1.obj == model2.obj %}
> print ok
> {% else %}
> print not OK
> {% endif %}
>
> but don't work.
>
> someone help me??
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/08860d9d-beb2-483a-81c2-1c9bbccb8899%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template tag don't work ==

2016-06-09 Thread Tim Graham
A sample project to reproduce the problem is probably needed.

On Thursday, June 9, 2016 at 12:33:24 PM UTC-4, Ing. Jaime Sanchez wrote:
>
> Help please!!
>
> I need do like this
> in django 1.9 template tag 
>
> {% if model1.obj == model2.obj %}
> print ok
> {% else %}
> print not OK
> {% endif %}
>
> but don't work.
>
> someone help me??
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/69ac610b-4099-43f0-b68e-a21e159f7585%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


template tag don't work ==

2016-06-09 Thread Ing. Jaime Sanchez
Help please!!

I need do like this
in django 1.9 template tag 

{% if model1.obj == model2.obj %}
print ok
{% else %}
print not OK
{% endif %}

but don't work.

someone help me??

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a53a5c6-8255-444f-b7ee-6ea20b399b87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


extend Media in custom template tag

2016-05-09 Thread guettli
 

I have a custom Django template tag which creates HTML.


This HTML needs some JS and CSS.


How can I extend the media list with my custom template tag?





-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc970f23-f6c5-4406-9e10-bcdbf0e74a2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Fwd: Built In Template Tag Request

2016-04-27 Thread Paul Kenjora
Hello,

  I sometimes have to pass more complex content into an include or another
tag as a variable.  The {% with %} tag and filters aren't enough to for
example render an HTML button and pass it into another include.

  I'd like to request a {% with_html variable %} tag in the built in tag
set.  Like the one below

@register.tag
> def with_html(parser, token):
>   nodelist = parser.parse(('endwith_html',))
>   parser.delete_first_token()
>   return WithHTML(nodelist, token.contents.split()[1])
>
> class WithHTML(template.Node):
>   def __init__(self, nodelist, variable):
> self.nodelist = nodelist
> self.variable = variable
>   def render(self, context):
> context[self.variable] = self.nodelist.render(context)
> return ''


A use case would be for example...

{% with_html extra %}
>   {% if row.0.ingredient_set.count %}{{ row.0.ingredient_set.count }}
> Ingredients{% endif %}
>   {% if row.0.step_set.count %}{{ row.0.step_set.count }} Steps{%
> endif %}
> {% endwith_html %}
> {% with item_title=row.0.title item_description=row.0.description
> item_image=row.0.image item_extra=extra item_link=row.0.link
> item_button=newsletter.recipe_button %}
>   {% include "newsletter/email_full.html" %}
> {% endwith %}


This type of tag would help keep the code more DRY in my opinion since the
rendering logic for the complex content doesn't need extra files and I can
now make includes more generic.  It would be a great compliment to the
already existing with tag.

-- 
- Paul Kenjora
- 602-214-7285

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEH8JE07Kcumv_TaMY-vSnLN3UaM3k8HScB5oT1Oi%3Dt%3DjcsF1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [django1.9] Url template tag, dotted path and decorator

2016-04-24 Thread knbk
In order to reverse a view by its dotted path, Django needs to know the 
actual path of the function. It uses the magic view.__module__ and 
view.__name__ attributes to determine the name. If your decorator doesn't 
copy these attributes from the inner function to the decorated function, 
Django doesn't know the path to the original function, and you can't 
reverse by dotted path.

As mentioned by Camilo, you can use functools.wraps() to fix this issue. 

On Sunday, April 24, 2016 at 3:54:20 AM UTC+2, Camilo Torres wrote:
>
> On Saturday, April 23, 2016 at 1:17:26 PM UTC-4:30, François Magimel wrote:
>>
>> Hi! 
>>
>> I'm facing an issue reversing a dotted path with django 1.9.4. Here are 
>> more details. 
>>
>> I pass a dotted path to the django template tag "url": 
>> "{% url 'my.app.view.func' arg %}" 
>> And the function "my.app.view.func" has a decorator which is using "arg". 
>> My problem is : when displaying my template, I get a NoReverseMatch error. 
>> But I don't have any error: 
>>   - when I use the name of the url (defined in my urls.py file) or 
>>   - when I use the dotted path and remove my (simple) decorator. 
>>
>> I know that passing a dotted path to url is deprecated since django 1.8 
>> [0][1], but not removed yet. So, I think there is something wrong with 
>> dotted path and decorators, but I can't find what… 
>>
>> PS: my decorator only redirects to another view… 
>>
>> Thanks, 
>> François 
>>
>>
>> [0] 
>> https://docs.djangoproject.com/en/1.8/releases/1.8/#passing-a-dotted-path-to-reverse-and-url
>>  
>> [1] https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#url 
>>
>
> Hi,
> May be you can use functools.wraps from Python standard library.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/17117f55-47ee-4fe8-9550-b9d9f9650c9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [django1.9] Url template tag, dotted path and decorator

2016-04-23 Thread Camilo Torres
On Saturday, April 23, 2016 at 1:17:26 PM UTC-4:30, François Magimel wrote:
>
> Hi! 
>
> I'm facing an issue reversing a dotted path with django 1.9.4. Here are 
> more details. 
>
> I pass a dotted path to the django template tag "url": 
> "{% url 'my.app.view.func' arg %}" 
> And the function "my.app.view.func" has a decorator which is using "arg". 
> My problem is : when displaying my template, I get a NoReverseMatch error. 
> But I don't have any error: 
>   - when I use the name of the url (defined in my urls.py file) or 
>   - when I use the dotted path and remove my (simple) decorator. 
>
> I know that passing a dotted path to url is deprecated since django 1.8 
> [0][1], but not removed yet. So, I think there is something wrong with 
> dotted path and decorators, but I can't find what… 
>
> PS: my decorator only redirects to another view… 
>
> Thanks, 
> François 
>
>
> [0] 
> https://docs.djangoproject.com/en/1.8/releases/1.8/#passing-a-dotted-path-to-reverse-and-url
>  
> [1] https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#url 
>

Hi,
May be you can use functools.wraps from Python standard library.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/31e70c60-a119-4bba-a903-6af4affd5bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[django1.9] Url template tag, dotted path and decorator

2016-04-23 Thread François Magimel
Hi!

I'm facing an issue reversing a dotted path with django 1.9.4. Here are more 
details.

I pass a dotted path to the django template tag "url":
"{% url 'my.app.view.func' arg %}"
And the function "my.app.view.func" has a decorator which is using "arg". My 
problem is : when displaying my template, I get a NoReverseMatch error.
But I don't have any error:
  - when I use the name of the url (defined in my urls.py file) or
  - when I use the dotted path and remove my (simple) decorator.

I know that passing a dotted path to url is deprecated since django 1.8 [0][1], 
but not removed yet. So, I think there is something wrong with dotted path and 
decorators, but I can't find what…

PS: my decorator only redirects to another view…

Thanks,
François


[0] 
https://docs.djangoproject.com/en/1.8/releases/1.8/#passing-a-dotted-path-to-reverse-and-url
[1] https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#url

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/785ab0e5-25a8-99b9-2106-f5c5d6a09880%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: STATIC_URL with thumbnail_url Template Tag

2015-07-10 Thread Luis Zárate
Hi, Stephanie

Your are using easy-thumbnails, right?
so, are you sure that Pillow are right installed ?

http://easy-thumbnails.readthedocs.org/en/latest/usage/

As I see your questions is same that this question
http://stackoverflow.com/questions/12956788/how-to-thumbnail-static-files


thumbnail_url is a wrapper for get-thumbnailer, so are you configure
static_root in your settings ?


http://easy-thumbnails.readthedocs.org/en/latest/usage/#get-thumbnailer



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyNbTgt8MweY0ZCJLGK9zKv_9kD-9NA6Az9BD7jFA5zfaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


STATIC_URL with thumbnail_url Template Tag

2015-06-30 Thread Stephanie Socias
Hello,

I'm trying to use an image from my 'static' folder in one of my templates. 
I need to pass the image into the thumbnail_url filter but I can't get it 
to work. The image is not found. How do I specify the correct image path? 
(I posted this same question on stackoverflow 
<http://stackoverflow.com/questions/31125560/static-url-with-thumbnail-url-template-tag>
 
yesterday.) Thank you!

I've tried this:

{% load thumbnail %}


{% with path="{{STATIC_URL}}/images/green-icon.png" %}

{% endwith %}


and also:

{% load thumbnail %}{% load staticfiles %}


-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/99f1e884-eee0-4329-a689-ce72a3c69522%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with url template tag and namespaces

2015-04-07 Thread donarb
On Tuesday, April 7, 2015 at 9:19:17 AM UTC-7, donarb wrote:
>
> I'm having a problem with a generated url using the url template tag, 
> currently using Django 1.6.5.
>
> The appname is 'dashboard', here is the main urls.py:
>
> urlpatterns = patterns("",
> (r'^dashboard/', include('dashboard.urls', namespace='dashboard')),
> )
>
>
>
> Here is the dashboard urls.py:
>
> # dashboard/urls.py
> urlpatterns = patterns("",
> (r'^players/', include('players.urls', namespace='players')),
> )
>
>
> Here is the players urls.py:
>
> # dashboard/players/urls.py
> urlpatterns = patterns("",
> url(r'^search/?', views.PlayerSearchView.as_view(), name='search'),
> )
>
>
>
> When I code this in the template:
>
> {% url "dashboard:players:search" %}
>
>
>
> I get this url:
>
> /dashboard/playerssearch
>
>
> Any idea why there is no path separator between 'players' and 'search'?
>


Just to follow up, I found the problem. The search url pattern had an 
optional trailing '/', so it was not creating the url correctly. Once I 
removed the optional from the regex, it worked. 

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a86d7bed-046a-4097-b607-5a6d7d6ecbd2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with url template tag and namespaces

2015-04-07 Thread donarb
I'm having a problem with a generated url using the url template tag, 
currently using Django 1.6.5.

The appname is 'dashboard', here is the main urls.py:

urlpatterns = patterns("",
(r'^dashboard/', include('dashboard.urls', namespace='dashboard')),
)



Here is the dashboard urls.py:

# dashboard/urls.py
urlpatterns = patterns("",
(r'^players/', include('players.urls', namespace='players')),
)


Here is the players urls.py:

# dashboard/players/urls.py
urlpatterns = patterns("",
url(r'^search/?', views.PlayerSearchView.as_view(), name='search'),
)



When I code this in the template:

{% url "dashboard:players:search" %}



I get this url:

/dashboard/playerssearch


Any idea why there is no path separator between 'players' and 'search'?

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e041c5f-8b68-43f2-9a32-0266e5d50588%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with a token in my custom template tag

2014-10-15 Thread Daniel Grace
I got it working thanks.  My template tag file is as follows:

from django import template
from django.utils import timezone
register = template.Library()

@register.simple_tag
def rowcolour(dt):
diff = timezone.now() - dt
if diff.days > 14:
return "pinkrow"
else:
return "greyrow"


-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7265a1a-6959-48b8-963e-5a73d420810f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with a token in my custom template tag

2014-10-15 Thread Daniel Roseman
On Wednesday, 15 October 2014 19:30:01 UTC+1, Daniel Grace wrote:
>
> Hi,
> I'm encountering the following problem with a token in my custom template 
> tag:
> Request Method: GET
> Request URL: http://127.0.0.1:8000/flows/
> Django Version: 1.7
> Exception Type: ValueError
> Exception Value: 
> need more than 2 values to unpack
> Exception Location: C:\landy\cresta\flow\templatetags\flow_extras.py in 
> rowcolour, line 7
>
> Here is the template file:
> from django import template
> from datetime import datetime, timedelta
> register = template.Library()
>
> @register.tag
> def rowcolour(parser, token):
> nm, dt, fmt = token.split_contents() # this is line 7
> diff = datetime.now() - dt 
> if diff.days > 14:
> return "pinkrow"
> else:
> return "greyrow"
>
> ... here is the line in the html file:
> 
>
> ... and "created" is defined as follows in the model:
> created = models.DateTimeField(db_index=True, auto_now_add=True)
>
> I'm trying to extract the datetime from the token.  Any ideas?
>
> Thanks.
>
>
Like the error says, you are telling it to split the result of 
`token.split_contents()` into three variables, but you are only passing it 
two elements: "rowcolour" and "flow.created". Where is `fmt` supposed to be 
coming from?

However, even when you fix that, this still won't work, as at that point 
`dt` will just be the string "row.created". You need to have a whole 
template Node in order to resolve variables like that. Why are you not 
using the `simple_tag` decorator, which is a shortcut for that whole 
process?

@register.simple_tag
def rowcolour(dt):
diff = datetime.now() - dt 
...etc...

--
DR.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b95004f-1905-4186-b4e4-26f859936777%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with a token in my custom template tag

2014-10-15 Thread Daniel Grace
Hi,
I'm encountering the following problem with a token in my custom template 
tag:
Request Method: GET
Request URL: http://127.0.0.1:8000/flows/
Django Version: 1.7
Exception Type: ValueError
Exception Value: 
need more than 2 values to unpack
Exception Location: C:\landy\cresta\flow\templatetags\flow_extras.py in 
rowcolour, line 7

Here is the template file:
from django import template
from datetime import datetime, timedelta
register = template.Library()

@register.tag
def rowcolour(parser, token):
nm, dt, fmt = token.split_contents() # this is line 7
diff = datetime.now() - dt 
if diff.days > 14:
return "pinkrow"
else:
return "greyrow"

... here is the line in the html file:


... and "created" is defined as follows in the model:
created = models.DateTimeField(db_index=True, auto_now_add=True)

I'm trying to extract the datetime from the token.  Any ideas?

Thanks.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2febd7e9-7f50-4741-bd4a-a82ca597f22c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Combining use of template tag + filter in same expression

2014-06-26 Thread Darren Spruell
I have a template in which I'm trying to achieve the use of the
'firstof' tag to display whichever of two variables is present, and
the resulting variable filtered through 'truncatewords'. Is there a
way this can be accomplished?

Have tried the following:

{% first of result.meta.summary|truncatewords:12
result.description|truncatewords:12 %}

It doesn't work as I thought it might, instead rendering 'None' in the template.

This construct seems to work as expected if only the last variable is
applied the filter:

{% firstof result.meta.summary result.description|truncatewords:2 %}

Can this be made to work? Or is the combination of firstof and a
filter on more than the last variable unsupported?

Python 2.7.7
Django 1.6.5

-- 
Darren Spruell
phatbuck...@gmail.com

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKVSOJUCLm1b4UBny31Z8MZxMUTxou0GR2WW5HsYn_vjcMvt5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: testing equality in template tag

2014-06-26 Thread Tom Evans
On Wed, Jun 25, 2014 at 7:34 PM, Lee Hinde  wrote:
> with view code like so:
>
> import calendar
> months_choices = []
> for i in range(1,13):
> months_choices.append((i, calendar.month_name[i]))
> context['months'] = months_choices
>
>
> and
>
> context['default_month'] = today.month
>
> I have this snippet in a template (my first use of lists like this):
>
> 
> {% for month in months %}
>  value="{{ month.0 }}">
> {{ month.1 }}
> {% endfor %}
> 
>
>
> The issue is the  {% if default_month == month.0 %} always returns false...
> The rest of the select is properly built - I get a number for the value and
> the month name as the label.
>
> Why?
>

Differing types? "1" != 1

Log the repr of both values and see.

Cheers

Tom

PS: Django forms are very good at rendering selects and determining
which one is selected.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1L%2B7USiPBr3LN66AB3ZSFQOc44aqvbu9_6G%3DOwETHEAjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: testing equality in template tag

2014-06-26 Thread Roman Klesel
Ugh , sorry of course we know ... forget what i said ...

2014-06-26 9:48 GMT+02:00 Roman Klesel :
> hard to tell since we do not know what values default_month and month.0 have 
> ...
> try to print in the view and examine:
> print type(month[0]), month[0], type(today.month), today.month
>
> 2014-06-25 20:34 GMT+02:00 Lee Hinde :
>> with view code like so:
>>
>> import calendar
>> months_choices = []
>> for i in range(1,13):
>> months_choices.append((i, calendar.month_name[i]))
>> context['months'] = months_choices
>>
>>
>> and
>>
>> context['default_month'] = today.month
>>
>> I have this snippet in a template (my first use of lists like this):
>>
>> 
>> {% for month in months %}
>> > value="{{ month.0 }}">
>> {{ month.1 }}
>> {% endfor %}
>> 
>>
>>
>> The issue is the  {% if default_month == month.0 %} always returns false...
>> The rest of the select is properly built - I get a number for the value and
>> the month name as the label.
>>
>> Why?
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2BePoMzx%2B4774Ne21djP-EdSAHDL_64DWhZVQYrUYdND%3DBk2%2Bw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL2Rd%3DKB6MxR22LTYQjVmxiee%2BhktpkqttPmemZQhvm9r9_%3DBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: testing equality in template tag

2014-06-26 Thread Roman Klesel
hard to tell since we do not know what values default_month and month.0 have ...
try to print in the view and examine:
print type(month[0]), month[0], type(today.month), today.month

2014-06-25 20:34 GMT+02:00 Lee Hinde :
> with view code like so:
>
> import calendar
> months_choices = []
> for i in range(1,13):
> months_choices.append((i, calendar.month_name[i]))
> context['months'] = months_choices
>
>
> and
>
> context['default_month'] = today.month
>
> I have this snippet in a template (my first use of lists like this):
>
> 
> {% for month in months %}
>  value="{{ month.0 }}">
> {{ month.1 }}
> {% endfor %}
> 
>
>
> The issue is the  {% if default_month == month.0 %} always returns false...
> The rest of the select is properly built - I get a number for the value and
> the month name as the label.
>
> Why?
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BePoMzx%2B4774Ne21djP-EdSAHDL_64DWhZVQYrUYdND%3DBk2%2Bw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL2Rd%3DJo__TO_U3OKAeehv4mRzBQEH4nMf0LfNxfoEZB4%2B9j%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


testing equality in template tag

2014-06-25 Thread Lee Hinde
with view code like so:

import calendar
months_choices = []
for i in range(1,13):
months_choices.append((i, calendar.month_name[i]))
context['months'] = months_choices


and

context['default_month'] = today.month

I have this snippet in a template (my first use of lists like this):


{% for month in months %}

{{ month.1 }}
{% endfor %}



The issue is the  {% if default_month == month.0 %} always returns false...
The rest of the select is properly built - I get a number for the value and
the month name as the label.

Why?

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BePoMzx%2B4774Ne21djP-EdSAHDL_64DWhZVQYrUYdND%3DBk2%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template tag render method doesn't get called

2014-02-16 Thread stevedegrace
This is a real problem. I have had the same issue, and I have seen several 
other people besides yourself bring this up without getting satisfactory 
answers.

I was having the same problem where __init__ was being called but not 
render, where the purpose of the tag is to insert several variables into 
the context and all it does is return an empty string. I don't know if this 
will work in your context, but it did in mine.

I was using the tag in a child template that extends by base template. I 
put the tag right after the load statement, but, *not within a {% block %}.*

When I put the tag within a block that is rendered, the render method got 
called and problem solved.

On Monday, June 2, 2008 9:54:26 AM UTC-3, Julien wrote:
>
> Similar issues have been raised in [1] and [2], but unfortunately I 
> could not find an answer for this. 
>
> Basically I have a custom template whose 'render' method never gets 
> called (the 'init', however, does): 
>
> class ShowParticipantNode(Node): 
> def __init__(self, participant, edit): 
> self.participant = participant 
> self.edit = edit 
>
> def render(self, context): 
> self.participant = self.participant.resolve(context) 
> request = resolve_variable('request', context) 
> context = {'me': request.user, 'participant': 
> self.participant } 
> if self.edit == 'edit': 
> return render_to_string('projects/units/ 
> participant_edit.html', context) 
> else: 
> return render_to_string('projects/units/participant.html', 
> context) 
>
> def show_participant(parser, token): 
> bits = token.contents.split(' ', 2) 
> if len(bits) > 3 : 
> raise TemplateSyntaxError("'%s' takes at most 2 argument" % 
> bits[0]) 
> if len(bits) == 3: 
> return ShowParticipantNode(parser.compile_filter(bits[1]), 
> bits[2]) 
> else: 
> return ShowParticipantNode(parser.compile_filter(bits[1]), 
> 'display') 
> show_participant = register.tag(show_participant) 
>
>
> Remark: I could not use a simple_tag for this as simple_tag doesn't 
> accept context as argument like inclusion_tag does. 
>
> The template is very simple, only a few lines: 
>
> {% load project_tags %} 
> {% for participant in participants %} 
> {% show_participant participant %} 
> {% endfor %} 
>
>
> The threads [1] and [2] mention inheritance, but I don't know if that 
> apply to my case. Do you know what I could do to troubleshoot this? 
>
> Thanks a lot! 
>
> Julien 
>
> [1] 
> http://groups.google.com/group/django-users/browse_thread/thread/4501aa624159b17d/1c363af87856a551
>  
> [2] 
> http://groups.google.com/group/django-users/browse_thread/thread/764df4d9a5b1dcc5/419fe0d904609e19

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f34c0806-da09-41a8-9070-0b2ca193e940%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Empty context within template tag render() method after using django.test.client.Client.login() method

2013-09-23 Thread Jonathan Baker
Below are some snippets involved in generating the error. The
'test_get_unauthenticated' works as expected, but 'test_get_ok' fails while
rendering the template response and calling the menu tag of django-menu
(full module:
https://github.com/rossp/django-menu/blob/master/menu/templatetags/menubuilder.py
).

*integration_tests.py*
class IntegrationTestCase(TestCase):
def setUp(self):
self.client = Client()
self.test_domain = "http://testserver";

class AccountDetail(IntegrationTestCase):
def test_get_unauthenticated(self):
"""302"""
destination = reverse("account_detail")
response = self.client.get(destination)
self.assertRedirects(response, reverse("login") + "?next=" +
destination)

def test_get_ok(self):
"""200"""
user = UserFactory.create()
self.client.login(username=user.username, password="testPass")
response = self.client.get(reverse("account_detail"))
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "accounts/account_detail.html")

*menubuilder.py*
class MenuObject(template.Node):
def __init__(self, menu_name):
self.menu_name = menu_name

def render(self, context):
current_path = context['request'].path
user = context['request'].user
context['menuitems'] = get_items(self.menu_name, current_path, user)
return ''


On Sun, Sep 22, 2013 at 5:36 PM, jondbaker wrote:

> Within my integration tests, it appears that after using the login()
> method of django.test.client.Client the context dict consists only of:
>
> [{'False': False, 'None': None, 'True': True}, {}, {}].
>
> If I remove the use of login(), then the request dict consists of:
>
> [{'False': False, 'None': None, 'True': True}, {'object':  te...@test.com>, 'user': , u'view':
> }, {u'csrf_token':
> }, {'perms':
> ,
> 'user': },
> {}, {u'MEDIA_URL': '/media/'}, {'messages':
>  0x1393c10>}, {u'request':  path:/accounts/,
> GET:,
> POST:,
> COOKIES:{'sessionid': 'q27przqeidsnfykuufu7m6lo7nw606qw'},
> META:{u'CONTENT_TYPE': 'text/html; charset=utf-8',
>  u'CSRF_COOKIE': u'9mWW7nGMJQAgbs3KBB3oEPofbLBCkLW2',
>  u'HTTP_COOKIE': u' sessionid=q27przqeidsnfykuufu7m6lo7nw606qw;
> Domain=None; expires=None; Max-Age=None; Path=/; secure',
>  u'PATH_INFO': u'/accounts/',
>  u'QUERY_STRING': '',
>  u'REMOTE_ADDR': '127.0.0.1',
>  u'REQUEST_METHOD': 'GET',
>  u'SCRIPT_NAME': u'',
>  u'SERVER_NAME': 'testserver',
>  u'SERVER_PORT': '80',
>  u'SERVER_PROTOCOL': 'HTTP/1.1',
>  u'wsgi.errors': <_io.BytesIO object at 0x2358050>,
>  u'wsgi.input': ,
>  u'wsgi.multiprocess': True,
>  u'wsgi.multithread': False,
>  u'wsgi.run_once': False,
>  u'wsgi.url_scheme': 'http',
>  u'wsgi.version': (1, 0)}>}, {u'STATIC_URL': '/static/'}, {}]
>
> I noticed the problem when a template tag was trying to access
> context["request"].path and a KeyError was raised after using login. Both
> outputs above are the result of printing the context var from within the
> render() method of a template tag. Any help would be greatly appreciated,
> as I'm a bit stumped.
>
> Thanks,
> Jonathan
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Empty context within template tag render() method after using django.test.client.Client.login() method

2013-09-22 Thread jondbaker
Within my integration tests, it appears that after using the login() method 
of django.test.client.Client the context dict consists only of: 

[{'False': False, 'None': None, 'True': True}, {}, {}].

If I remove the use of login(), then the request dict consists of:

[{'False': False, 'None': None, 'True': True}, {'object': , 'user': , u'view': 
}, {u'csrf_token': 
}, {'perms': 
, 
'user': }, 
{}, {u'MEDIA_URL': '/media/'}, {'messages': 
}, {u'request': ,
POST:,
COOKIES:{'sessionid': 'q27przqeidsnfykuufu7m6lo7nw606qw'},
META:{u'CONTENT_TYPE': 'text/html; charset=utf-8',
 u'CSRF_COOKIE': u'9mWW7nGMJQAgbs3KBB3oEPofbLBCkLW2',
 u'HTTP_COOKIE': u' sessionid=q27przqeidsnfykuufu7m6lo7nw606qw; 
Domain=None; expires=None; Max-Age=None; Path=/; secure',
 u'PATH_INFO': u'/accounts/',
 u'QUERY_STRING': '',
 u'REMOTE_ADDR': '127.0.0.1',
 u'REQUEST_METHOD': 'GET',
 u'SCRIPT_NAME': u'',
 u'SERVER_NAME': 'testserver',
 u'SERVER_PORT': '80',
 u'SERVER_PROTOCOL': 'HTTP/1.1',
 u'wsgi.errors': <_io.BytesIO object at 0x2358050>,
 u'wsgi.input': ,
 u'wsgi.multiprocess': True,
 u'wsgi.multithread': False,
 u'wsgi.run_once': False,
 u'wsgi.url_scheme': 'http',
 u'wsgi.version': (1, 0)}>}, {u'STATIC_URL': '/static/'}, {}]

I noticed the problem when a template tag was trying to access 
context["request"].path and a KeyError was raised after using login. Both 
outputs above are the result of printing the context var from within the 
render() method of a template tag. Any help would be greatly appreciated, 
as I'm a bit stumped.

Thanks,
Jonathan

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How template tag can receive values JS

2013-08-01 Thread Bill Freeman
If this is only to be done when loading a new page, then you could add the
JS var value to the request as a query parameter.  Then the view would have
to pass the value to the template for the new page.


On Thu, Aug 1, 2013 at 9:51 AM, Christian Erhardt <
christian.erha...@mojo2k.de> wrote:

> No, what you are trying is not possible. The template tags are rendered on
> the server. They never appear on the client machine. Javascript is running
> on the client machine. They both will never see each other.
>
> You will always have to do a roundtrip to interact between Javascript and
> django templates: send a request from Javascript to the server, server
> renders the page and returns it.
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How template tag can receive values JS

2013-08-01 Thread Christian Erhardt
No, what you are trying is not possible. The template tags are rendered on the 
server. They never appear on the client machine. Javascript is running on the 
client machine. They both will never see each other.

You will always have to do a roundtrip to interact between Javascript and 
django templates: send a request from Javascript to the server, server renders 
the page and returns it.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How template tag can receive values JS

2013-08-01 Thread Larry Martell
On Thu, Aug 1, 2013 at 6:48 AM, Mário Idival  wrote:
> Good morning everyone,
> I wonder how I can do (and if it is possible), pass a value of javascript
> variable to a template tag Django.
>
> eg
> how it works:
> {{Document.id | split_filter}} -> split_filter is just a random method,
> receives an ID
>
> as would
> {{"Value Var JS" | split_filter}} -> pass the id that comes from a JS
> variable to the template tag.

You could pass something from js using ajax back to python, which then
passes it to a template.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How template tag can receive values JS

2013-08-01 Thread Mário Idival
Good morning everyone,
I wonder how I can do (and if it is possible), pass a value of javascript
variable to a template tag Django.

eg
how it works:
{{Document.id | split_filter}} -> split_filter is just a random method,
receives an ID

as would
{{"Value Var JS" | split_filter}} -> pass the id that comes from a JS
variable to the template tag.

Thanks.
Mário Idival

*Twitter *: *@marioigd*
*Facebook*: *mario.idival*
*User Linux : **#554446*
Skype*: marioidival*
*Blog:  *https://conconcus.wordpress.com

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django dynamic template tag

2013-07-13 Thread Andriyko



Try {{ pagecontent.plugin }} instead of {% pagecontent.plugin %}



On Wednesday, July 3, 2013 3:11:08 AM UTC+3, Fadi Samara wrote:
>
> I try to build a plugins based application, I have created tags and 
> registered them for each plugin.
>
> I have a table stores each page plugins, and need to render any stored 
> plugin in the template accordingly as inclusion tag.
>
> Now for the template i use this:
>
> {% block slider_region %}{% for pagecontent in pagecontents %}
> {% pagecontent.plugin %}{% endfor %}{% endblock %}
>
> But this returns:
>
> Invalid block tag: 'pagecontent.plugin', expected 'empty' or 'endfor'
>
> My question, how can I pass the plugin as a tag from view query to a 
> template and be rendered as inclusion tag.
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django dynamic template tag

2013-07-03 Thread Fadi Samara
Hi Fred,

its already included at the start of the template to load all plugin tags 
{% load slider ...%}

Thanks,


On Wednesday, July 3, 2013 11:00:31 PM UTC+10, Fred Stluka wrote:
>
>  Fadi,
>
> You need to {% load %} the file that defines the tags.
>
> --Fred 
> --
> Fred Stluka -- mailt...@bristle.com  -- 
> http://bristle.com/~fred/ 
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service! 
> Open Source: Without walls and fences, we need no Windows or Gates. 
> --
>  
> On 7/2/13 8:11 PM, Fadi Samara wrote: 
>
>  I try to build a plugins based application, I have created tags and 
> registered them for each plugin.
>
> I have a table stores each page plugins, and need to render any stored 
> plugin in the template accordingly as inclusion tag.
>
> Now for the template i use this:
>
> {% block slider_region %}{% for pagecontent in pagecontents %}
> {% pagecontent.plugin %}{% endfor %}{% endblock %}
>
>  But this returns:
>
> Invalid block tag: 'pagecontent.plugin', expected 'empty' or 'endfor'
>
> My question, how can I pass the plugin as a tag from view query to a 
> template and be rendered as inclusion tag.
>  -- 
> 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...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>  

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django dynamic template tag

2013-07-03 Thread Fadi Samara
its already included at the start of the template to load all plugin tags
{% load slider ...%}


Regards,
Fadi Samara.


On Wed, Jul 3, 2013 at 11:00 PM, Fred Stluka  wrote:

>  Fadi,
>
> You need to {% load %} the file that defines the tags.
>
> --Fred
> --
> Fred Stluka -- mailto:f...@bristle.com  --
> http://bristle.com/~fred/
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
> Open Source: Without walls and fences, we need no Windows or Gates.
> --
>
> On 7/2/13 8:11 PM, Fadi Samara wrote:
>
>  I try to build a plugins based application, I have created tags and
> registered them for each plugin.
>
> I have a table stores each page plugins, and need to render any stored
> plugin in the template accordingly as inclusion tag.
>
> Now for the template i use this:
>
> {% block slider_region %}{% for pagecontent in pagecontents %}
> {% pagecontent.plugin %}{% endfor %}{% endblock %}
>
>  But this returns:
>
> Invalid block tag: 'pagecontent.plugin', expected 'empty' or 'endfor'
>
> My question, how can I pass the plugin as a tag from view query to a
> template and be rendered as inclusion tag.
>  --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/AukAEPmgq_A/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django dynamic template tag

2013-07-03 Thread Fred Stluka

Fadi,

You need to {% load %} the file that defines the tags.

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 7/2/13 8:11 PM, Fadi Samara wrote:


I try to build a plugins based application, I have created tags and 
registered them for each plugin.


I have a table stores each page plugins, and need to render any stored 
plugin in the template accordingly as inclusion tag.


Now for the template i use this:

|{%  block slider_region%}
{%  for  pagecontentin  pagecontents%}
 {%  pagecontent.plugin%}
{%  endfor%}
{%  endblock%}|

But this returns:

|Invalid  block tag:  'pagecontent.plugin',  expected'empty'  or  'endfor'

|

My question, how can I pass the plugin as a tag from view query to a 
template and be rendered as inclusion tag.


--
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




--
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




django dynamic template tag

2013-07-02 Thread Fadi Samara
 

I try to build a plugins based application, I have created tags and 
registered them for each plugin.

I have a table stores each page plugins, and need to render any stored 
plugin in the template accordingly as inclusion tag.

Now for the template i use this:

{% block slider_region %}{% for pagecontent in pagecontents %}
{% pagecontent.plugin %}{% endfor %}{% endblock %}

But this returns:

Invalid block tag: 'pagecontent.plugin', expected 'empty' or 'endfor'

My question, how can I pass the plugin as a tag from view query to a 
template and be rendered as inclusion tag.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Access request object in a custom template tag

2013-04-29 Thread Ponytech
Hello,

I am currently writing a custom template tag and I need to access the 
request object within the tag code.
When using tag helpers (*simple_tag*, *inclusion_tag *and *assignment_tag*) 
you can register them with an additional takes_context=True parameter that 
makes the request object available.
But this does not work with the low level *tag* decorator:

@register.tag(takes_context=True)def mytag(parser, token):
   ...

raises the exception:  *tag() got an unexpected keyword argument 
'takes_context'*
*
*
2 questions :

- is there a reason why the tag decorator does accept the takes_context 
argument ?
- how can I access the template context with this decorator (and thus the 
request object) ?


Thanks a lot.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Issue resolved.

The problem was a similar usage of a url template tag without a namespace -
in the same template. All I had to do was check the correct line number in
the template.

Thanks to all. Time for a walk outside.


On Tue, Apr 9, 2013 at 5:36 PM, Sithembewena Lloyd Dube
wrote:

> New trace below: I am stumped.
>
> Request Method: GET  Request URL: http://127.0.0.1:8000/contact_us/  Django
> Version: 1.5.1  Exception Type: NoReverseMatch  Exception Value:
>
> Reverse for 'contact_us' with arguments '()' and keyword arguments '{}' not 
> found.
>
>
>
>
> On Tue, Apr 9, 2013 at 5:34 PM, Sithembewena Lloyd Dube  > wrote:
>
>> Hi all,
>>
>> I have the correct url, but the dev server seems to be caching my old
>> template, even though I updated it to include namespacing. I have restarted
>> the server and cleared my browser cache.
>>
>> contacts
>>
>>
>> On Tue, Apr 9, 2013 at 5:11 PM, Sithembewena Lloyd Dube <
>> zebr...@gmail.com> wrote:
>>
>>> Tom,
>>>
>>> The latter. I did not call reverse explicitly (not yet). I have
>>> implemented namespacing as recommended.
>>>
>>> Contact Us
>>>
>>> Sinister indeed.
>>>
>>>
>>> On Tue, Apr 9, 2013 at 4:59 PM, Tom Evans wrote:
>>>
>>>> On Tue, Apr 9, 2013 at 3:56 PM, Sithembewena Lloyd Dube
>>>>  wrote:
>>>> > Hi Tom,
>>>> >
>>>> > I see what you meant. In the documentation (tutorial) namespacing is
>>>> used in
>>>> > the form example. Even with that in place, I am having trouble.
>>>> >
>>>> > I did notice that I am not getting a 404 error instead, because the
>>>> url
>>>> > being built is dumplicated. Please see the trace below (errant line
>>>> ibeing
>>>> > #8):
>>>> >
>>>> > Using the URLconf defined in tjbengineeringsite.urls, Django tried
>>>> these URL
>>>> > patterns, in this order:
>>>> >
>>>> > ^$ [name='plant_refurbishment']
>>>> > ^about_us/$ [name='about_us']
>>>> > ^instrumentation_and_control/$ [name='instrumentation_and_control']
>>>> > ^machining/$ [name='machining']
>>>> > ^industrial_solutions/$ [name='industrial_solutions']
>>>> > ^trailer_refurbishment/$ [name='trailer_refurbishment']
>>>> > ^trailer_spares/$ [name='trailer_spares']
>>>> > ^contact_us/ ^$ [name='contact_us']
>>>> > ^admin/
>>>> >
>>>> > The current URL, contact_us/contact_us/, didn't match any of these.
>>>> >
>>>>
>>>> Are you saying that this url was the result of calling reverse() (or {%
>>>> url %})?
>>>>
>>>> Cheers
>>>>
>>>> Tom
>>>>
>>>> --
>>>> 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 this group, send email to django-users@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Regards,
>>> Sithu Lloyd Dube
>>>
>>
>>
>>
>> --
>> Regards,
>> Sithu Lloyd Dube
>>
>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Issue resolved.

The problem was a similar usage of a url template tag without a namespace.
All I had to do was check the correct line number in the template.

Thanks to all. Time for a walk outside.


On Tue, Apr 9, 2013 at 5:36 PM, Sithembewena Lloyd Dube
wrote:

> New trace below: I am stumped.
>
> Request Method: GET  Request URL: http://127.0.0.1:8000/contact_us/  Django
> Version: 1.5.1  Exception Type: NoReverseMatch  Exception Value:
>
> Reverse for 'contact_us' with arguments '()' and keyword arguments '{}' not 
> found.
>
>
>
>
> On Tue, Apr 9, 2013 at 5:34 PM, Sithembewena Lloyd Dube  > wrote:
>
>> Hi all,
>>
>> I have the correct url, but the dev server seems to be caching my old
>> template, even though I updated it to include namespacing. I have restarted
>> the server and cleared my browser cache.
>>
>> contacts
>>
>>
>> On Tue, Apr 9, 2013 at 5:11 PM, Sithembewena Lloyd Dube <
>> zebr...@gmail.com> wrote:
>>
>>> Tom,
>>>
>>> The latter. I did not call reverse explicitly (not yet). I have
>>> implemented namespacing as recommended.
>>>
>>> Contact Us
>>>
>>> Sinister indeed.
>>>
>>>
>>> On Tue, Apr 9, 2013 at 4:59 PM, Tom Evans wrote:
>>>
>>>> On Tue, Apr 9, 2013 at 3:56 PM, Sithembewena Lloyd Dube
>>>>  wrote:
>>>> > Hi Tom,
>>>> >
>>>> > I see what you meant. In the documentation (tutorial) namespacing is
>>>> used in
>>>> > the form example. Even with that in place, I am having trouble.
>>>> >
>>>> > I did notice that I am not getting a 404 error instead, because the
>>>> url
>>>> > being built is dumplicated. Please see the trace below (errant line
>>>> ibeing
>>>> > #8):
>>>> >
>>>> > Using the URLconf defined in tjbengineeringsite.urls, Django tried
>>>> these URL
>>>> > patterns, in this order:
>>>> >
>>>> > ^$ [name='plant_refurbishment']
>>>> > ^about_us/$ [name='about_us']
>>>> > ^instrumentation_and_control/$ [name='instrumentation_and_control']
>>>> > ^machining/$ [name='machining']
>>>> > ^industrial_solutions/$ [name='industrial_solutions']
>>>> > ^trailer_refurbishment/$ [name='trailer_refurbishment']
>>>> > ^trailer_spares/$ [name='trailer_spares']
>>>> > ^contact_us/ ^$ [name='contact_us']
>>>> > ^admin/
>>>> >
>>>> > The current URL, contact_us/contact_us/, didn't match any of these.
>>>> >
>>>>
>>>> Are you saying that this url was the result of calling reverse() (or {%
>>>> url %})?
>>>>
>>>> Cheers
>>>>
>>>> Tom
>>>>
>>>> --
>>>> 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 this group, send email to django-users@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Regards,
>>> Sithu Lloyd Dube
>>>
>>
>>
>>
>> --
>> Regards,
>> Sithu Lloyd Dube
>>
>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
New trace below: I am stumped.

Request Method: GET  Request URL: http://127.0.0.1:8000/contact_us/  Django
Version: 1.5.1  Exception Type: NoReverseMatch  Exception Value:

Reverse for 'contact_us' with arguments '()' and keyword arguments
'{}' not found.




On Tue, Apr 9, 2013 at 5:34 PM, Sithembewena Lloyd Dube
wrote:

> Hi all,
>
> I have the correct url, but the dev server seems to be caching my old
> template, even though I updated it to include namespacing. I have restarted
> the server and cleared my browser cache.
>
> contacts
>
>
> On Tue, Apr 9, 2013 at 5:11 PM, Sithembewena Lloyd Dube  > wrote:
>
>> Tom,
>>
>> The latter. I did not call reverse explicitly (not yet). I have
>> implemented namespacing as recommended.
>>
>> Contact Us
>>
>> Sinister indeed.
>>
>>
>> On Tue, Apr 9, 2013 at 4:59 PM, Tom Evans wrote:
>>
>>> On Tue, Apr 9, 2013 at 3:56 PM, Sithembewena Lloyd Dube
>>>  wrote:
>>> > Hi Tom,
>>> >
>>> > I see what you meant. In the documentation (tutorial) namespacing is
>>> used in
>>> > the form example. Even with that in place, I am having trouble.
>>> >
>>> > I did notice that I am not getting a 404 error instead, because the url
>>> > being built is dumplicated. Please see the trace below (errant line
>>> ibeing
>>> > #8):
>>> >
>>> > Using the URLconf defined in tjbengineeringsite.urls, Django tried
>>> these URL
>>> > patterns, in this order:
>>> >
>>> > ^$ [name='plant_refurbishment']
>>> > ^about_us/$ [name='about_us']
>>> > ^instrumentation_and_control/$ [name='instrumentation_and_control']
>>> > ^machining/$ [name='machining']
>>> > ^industrial_solutions/$ [name='industrial_solutions']
>>> > ^trailer_refurbishment/$ [name='trailer_refurbishment']
>>> > ^trailer_spares/$ [name='trailer_spares']
>>> > ^contact_us/ ^$ [name='contact_us']
>>> > ^admin/
>>> >
>>> > The current URL, contact_us/contact_us/, didn't match any of these.
>>> >
>>>
>>> Are you saying that this url was the result of calling reverse() (or {%
>>> url %})?
>>>
>>> Cheers
>>>
>>> Tom
>>>
>>> --
>>> 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 this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
>> --
>> Regards,
>> Sithu Lloyd Dube
>>
>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Hi all,

I have the correct url, but the dev server seems to be caching my old
template, even though I updated it to include namespacing. I have restarted
the server and cleared my browser cache.

contacts


On Tue, Apr 9, 2013 at 5:11 PM, Sithembewena Lloyd Dube
wrote:

> Tom,
>
> The latter. I did not call reverse explicitly (not yet). I have
> implemented namespacing as recommended.
>
> Contact Us
>
> Sinister indeed.
>
>
> On Tue, Apr 9, 2013 at 4:59 PM, Tom Evans wrote:
>
>> On Tue, Apr 9, 2013 at 3:56 PM, Sithembewena Lloyd Dube
>>  wrote:
>> > Hi Tom,
>> >
>> > I see what you meant. In the documentation (tutorial) namespacing is
>> used in
>> > the form example. Even with that in place, I am having trouble.
>> >
>> > I did notice that I am not getting a 404 error instead, because the url
>> > being built is dumplicated. Please see the trace below (errant line
>> ibeing
>> > #8):
>> >
>> > Using the URLconf defined in tjbengineeringsite.urls, Django tried
>> these URL
>> > patterns, in this order:
>> >
>> > ^$ [name='plant_refurbishment']
>> > ^about_us/$ [name='about_us']
>> > ^instrumentation_and_control/$ [name='instrumentation_and_control']
>> > ^machining/$ [name='machining']
>> > ^industrial_solutions/$ [name='industrial_solutions']
>> > ^trailer_refurbishment/$ [name='trailer_refurbishment']
>> > ^trailer_spares/$ [name='trailer_spares']
>> > ^contact_us/ ^$ [name='contact_us']
>> > ^admin/
>> >
>> > The current URL, contact_us/contact_us/, didn't match any of these.
>> >
>>
>> Are you saying that this url was the result of calling reverse() (or {%
>> url %})?
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Tom,

The latter. I did not call reverse explicitly (not yet). I have implemented
namespacing as recommended.

Contact Us




On Tue, Apr 9, 2013 at 4:59 PM, Tom Evans  wrote:

> On Tue, Apr 9, 2013 at 3:56 PM, Sithembewena Lloyd Dube
>  wrote:
> > Hi Tom,
> >
> > I see what you meant. In the documentation (tutorial) namespacing is
> used in
> > the form example. Even with that in place, I am having trouble.
> >
> > I did notice that I am not getting a 404 error instead, because the url
> > being built is dumplicated. Please see the trace below (errant line
> ibeing
> > #8):
> >
> > Using the URLconf defined in tjbengineeringsite.urls, Django tried these
> URL
> > patterns, in this order:
> >
> > ^$ [name='plant_refurbishment']
> > ^about_us/$ [name='about_us']
> > ^instrumentation_and_control/$ [name='instrumentation_and_control']
> > ^machining/$ [name='machining']
> > ^industrial_solutions/$ [name='industrial_solutions']
> > ^trailer_refurbishment/$ [name='trailer_refurbishment']
> > ^trailer_spares/$ [name='trailer_spares']
> > ^contact_us/ ^$ [name='contact_us']
> > ^admin/
> >
> > The current URL, contact_us/contact_us/, didn't match any of these.
> >
>
> Are you saying that this url was the result of calling reverse() (or {%
> url %})?
>
> Cheers
>
> Tom
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Tom Evans
On Tue, Apr 9, 2013 at 3:56 PM, Sithembewena Lloyd Dube
 wrote:
> Hi Tom,
>
> I see what you meant. In the documentation (tutorial) namespacing is used in
> the form example. Even with that in place, I am having trouble.
>
> I did notice that I am not getting a 404 error instead, because the url
> being built is dumplicated. Please see the trace below (errant line ibeing
> #8):
>
> Using the URLconf defined in tjbengineeringsite.urls, Django tried these URL
> patterns, in this order:
>
> ^$ [name='plant_refurbishment']
> ^about_us/$ [name='about_us']
> ^instrumentation_and_control/$ [name='instrumentation_and_control']
> ^machining/$ [name='machining']
> ^industrial_solutions/$ [name='industrial_solutions']
> ^trailer_refurbishment/$ [name='trailer_refurbishment']
> ^trailer_spares/$ [name='trailer_spares']
> ^contact_us/ ^$ [name='contact_us']
> ^admin/
>
> The current URL, contact_us/contact_us/, didn't match any of these.
>

Are you saying that this url was the result of calling reverse() (or {% url %})?

Cheers

Tom

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Tom Evans
On Tue, Apr 9, 2013 at 3:43 PM, Sithembewena Lloyd Dube
 wrote:
> Thanks, Tom.
>
> I am not sure how you mean? In the contact_us app, I am not explicitly
> calling reverse. I only have the following:
>
> from django.shortcuts import render, reverse
>
> def contact_us(request):
> return render(request, 'contact_us/contact_us.html')
>

In your template you have

  {% url 'contact_us' %}

But in your urls.py you have given all urls in that app a namespace.
Therefore, you must use the namespace if you wish to reverse it - the
url tag simply calls reverse(). Hence:

  {% url 'contact_us:contact_us %}

Cheers

Tom

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Hi Tom,

I see what you meant. In the documentation (tutorial) namespacing is used
in the form example. Even with that in place, I am having trouble.

I did notice that I am not getting a 404 error instead, because the url
being built is dumplicated. Please see the trace below (errant line ibeing
#8):

 Using the URLconf defined in mysite.urls, Django tried these URL patterns,
in this order:

   1. ^$ [name='plant_refurbishment']
   2. ^about_us/$ [name='about_us']
   3. ^instrumentation_and_control/$ [name='instrumentation_and_control']
   4. ^machining/$ [name='machining']
   5. ^industrial_solutions/$ [name='industrial_solutions']
   6. ^trailer_refurbishment/$ [name='trailer_refurbishment']
   7. ^trailer_spares/$ [name='trailer_spares']
   8. ^contact_us/ ^$ [name='contact_us']
   9. ^admin/

The current URL, contact_us/contact_us/, didn't match any of these.


On Tue, Apr 9, 2013 at 4:43 PM, Sithembewena Lloyd Dube
wrote:

> Thanks, Tom.
>
> I am not sure how you mean? In the contact_us app, I am not explicitly
> calling reverse. I only have the following:
>
> from django.shortcuts import render, reverse
>
> def contact_us(request):
> return render(request, 'contact_us/contact_us.html')
>
>
>
>
> On Tue, Apr 9, 2013 at 4:22 PM, Tom Evans wrote:
>
>> On Tue, Apr 9, 2013 at 2:31 PM, Sithembewena Lloyd Dube
>>  wrote:
>> > Hi everyone,
>> >
>> > I have a project based on the latest Django version (1.5.1.) where I
>> created
>> > a contact_us application. The project has a urls.py file with some url
>> > patterns. The contact_us app implements its own urls.py file
>> (decoupling).
>> > In the project's urls.py file (just above the admin site's url
>> pattern), i
>> > have the following url pattern:
>> >
>> > url(r'^contact_us/', include('contact_us.urls',
>> namespace="contact_us")),
>> >
>> > and in the contact_us app's urls.py file, I have the following url
>> pattern:
>> >
>> > urlpatterns = patterns('',
>> > url(r'^$', views.contact_us, name='contact_us'),
>> > )
>> >
>> > In a template residing in the contact_us app's own templates folder, I
>> use
>> > the url template tag as follows:
>> >
>> > Contact Us
>> >
>> > resulting in the following exception:
>> >
>> > NoReverseMatch at /contact_us/
>> >
>> > Reverse for 'contact_us' with arguments '()' and keyword arguments '{}'
>> not
>> > found.
>> >
>> > Any ideas what I could be missing? I namespaced the contact_us urls
>> include
>> > in the main urls'py file and there is a simple contact_us view in the
>> > contact_us app which renders an existing template.
>> >
>> > Thanks.
>>
>> You've omitted the namespace when reversing the url. Use
>> 'contact_us:contact_us'.
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Hi Tom,

I see what you meant. In the documentation (tutorial) namespacing is used
in the form example. Even with that in place, I am having trouble.

I did notice that I am not getting a 404 error instead, because the url
being built is dumplicated. Please see the trace below (errant line ibeing
#8):

 Using the URLconf defined in tjbengineeringsite.urls, Django tried these
URL patterns, in this order:

   1. ^$ [name='plant_refurbishment']
   2. ^about_us/$ [name='about_us']
   3. ^instrumentation_and_control/$ [name='instrumentation_and_control']
   4. ^machining/$ [name='machining']
   5. ^industrial_solutions/$ [name='industrial_solutions']
   6. ^trailer_refurbishment/$ [name='trailer_refurbishment']
   7. ^trailer_spares/$ [name='trailer_spares']
   8. ^contact_us/ ^$ [name='contact_us']
   9. ^admin/

The current URL, contact_us/contact_us/, didn't match any of these.



On Tue, Apr 9, 2013 at 4:43 PM, Sithembewena Lloyd Dube
wrote:

> Thanks, Tom.
>
> I am not sure how you mean? In the contact_us app, I am not explicitly
> calling reverse. I only have the following:
>
> from django.shortcuts import render, reverse
>
> def contact_us(request):
> return render(request, 'contact_us/contact_us.html')
>
>
>
>
> On Tue, Apr 9, 2013 at 4:22 PM, Tom Evans wrote:
>
>> On Tue, Apr 9, 2013 at 2:31 PM, Sithembewena Lloyd Dube
>>  wrote:
>> > Hi everyone,
>> >
>> > I have a project based on the latest Django version (1.5.1.) where I
>> created
>> > a contact_us application. The project has a urls.py file with some url
>> > patterns. The contact_us app implements its own urls.py file
>> (decoupling).
>> > In the project's urls.py file (just above the admin site's url
>> pattern), i
>> > have the following url pattern:
>> >
>> > url(r'^contact_us/', include('contact_us.urls',
>> namespace="contact_us")),
>> >
>> > and in the contact_us app's urls.py file, I have the following url
>> pattern:
>> >
>> > urlpatterns = patterns('',
>> > url(r'^$', views.contact_us, name='contact_us'),
>> > )
>> >
>> > In a template residing in the contact_us app's own templates folder, I
>> use
>> > the url template tag as follows:
>> >
>> > Contact Us
>> >
>> > resulting in the following exception:
>> >
>> > NoReverseMatch at /contact_us/
>> >
>> > Reverse for 'contact_us' with arguments '()' and keyword arguments '{}'
>> not
>> > found.
>> >
>> > Any ideas what I could be missing? I namespaced the contact_us urls
>> include
>> > in the main urls'py file and there is a simple contact_us view in the
>> > contact_us app which renders an existing template.
>> >
>> > Thanks.
>>
>> You've omitted the namespace when reversing the url. Use
>> 'contact_us:contact_us'.
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>



-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Thanks, Tom.

I am not sure how you mean? In the contact_us app, I am not explicitly
calling reverse. I only have the following:

from django.shortcuts import render, reverse

def contact_us(request):
return render(request, 'contact_us/contact_us.html')




On Tue, Apr 9, 2013 at 4:22 PM, Tom Evans  wrote:

> On Tue, Apr 9, 2013 at 2:31 PM, Sithembewena Lloyd Dube
>  wrote:
> > Hi everyone,
> >
> > I have a project based on the latest Django version (1.5.1.) where I
> created
> > a contact_us application. The project has a urls.py file with some url
> > patterns. The contact_us app implements its own urls.py file
> (decoupling).
> > In the project's urls.py file (just above the admin site's url pattern),
> i
> > have the following url pattern:
> >
> > url(r'^contact_us/', include('contact_us.urls', namespace="contact_us")),
> >
> > and in the contact_us app's urls.py file, I have the following url
> pattern:
> >
> > urlpatterns = patterns('',
> >     url(r'^$', views.contact_us, name='contact_us'),
> > )
> >
> > In a template residing in the contact_us app's own templates folder, I
> use
> > the url template tag as follows:
> >
> > Contact Us
> >
> > resulting in the following exception:
> >
> > NoReverseMatch at /contact_us/
> >
> > Reverse for 'contact_us' with arguments '()' and keyword arguments '{}'
> not
> > found.
> >
> > Any ideas what I could be missing? I namespaced the contact_us urls
> include
> > in the main urls'py file and there is a simple contact_us view in the
> > contact_us app which renders an existing template.
> >
> > Thanks.
>
> You've omitted the namespace when reversing the url. Use
> 'contact_us:contact_us'.
>
> Cheers
>
> Tom
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Tom Evans
On Tue, Apr 9, 2013 at 2:31 PM, Sithembewena Lloyd Dube
 wrote:
> Hi everyone,
>
> I have a project based on the latest Django version (1.5.1.) where I created
> a contact_us application. The project has a urls.py file with some url
> patterns. The contact_us app implements its own urls.py file (decoupling).
> In the project's urls.py file (just above the admin site's url pattern), i
> have the following url pattern:
>
> url(r'^contact_us/', include('contact_us.urls', namespace="contact_us")),
>
> and in the contact_us app's urls.py file, I have the following url pattern:
>
> urlpatterns = patterns('',
> url(r'^$', views.contact_us, name='contact_us'),
> )
>
> In a template residing in the contact_us app's own templates folder, I use
> the url template tag as follows:
>
> Contact Us
>
> resulting in the following exception:
>
> NoReverseMatch at /contact_us/
>
> Reverse for 'contact_us' with arguments '()' and keyword arguments '{}' not
> found.
>
> Any ideas what I could be missing? I namespaced the contact_us urls include
> in the main urls'py file and there is a simple contact_us view in the
> contact_us app which renders an existing template.
>
> Thanks.

You've omitted the namespace when reversing the url. Use
'contact_us:contact_us'.

Cheers

Tom

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Andrey Kostakov
I am not sure, but you can try following code in your contact_us app's urls.py:
urlpatterns = patterns('contact_us.views',
url(r'^$', views.contact_us, name='contact_us'),
)


On Tue, Apr 9, 2013 at 6:02 PM, Sithembewena Lloyd Dube
 wrote:
> Hi Andrey,
>
> Thanks for the suggestion. I tried that with no success. According to the
> current documentation, that would be an issue with versions older than 1.5?
> (where one would use url from future).
>
> For some reason, i suspect that the url tag cannot resolve a url for a view
> in a "plugged-in" app? (base url + app-view url?).
>
>
> On Tue, Apr 9, 2013 at 3:40 PM, Andrey Kostakov  wrote:
>>
>> Try this without quotes:
>> Contact Us
>>
>> On Tue, Apr 9, 2013 at 5:31 PM, Sithembewena Lloyd Dube
>>  wrote:
>> > Hi everyone,
>> >
>> > I have a project based on the latest Django version (1.5.1.) where I
>> > created
>> > a contact_us application. The project has a urls.py file with some url
>> > patterns. The contact_us app implements its own urls.py file
>> > (decoupling).
>> > In the project's urls.py file (just above the admin site's url pattern),
>> > i
>> > have the following url pattern:
>> >
>> > url(r'^contact_us/', include('contact_us.urls',
>> > namespace="contact_us")),
>> >
>> > and in the contact_us app's urls.py file, I have the following url
>> > pattern:
>> >
>> > urlpatterns = patterns('',
>> > url(r'^$', views.contact_us, name='contact_us'),
>> > )
>> >
>> > In a template residing in the contact_us app's own templates folder, I
>> > use
>> > the url template tag as follows:
>> >
>> > Contact Us
>> >
>> > resulting in the following exception:
>> >
>> > NoReverseMatch at /contact_us/
>> >
>> > Reverse for 'contact_us' with arguments '()' and keyword arguments '{}'
>> > not
>> > found.
>> >
>> > Any ideas what I could be missing? I namespaced the contact_us urls
>> > include
>> > in the main urls'py file and there is a simple contact_us view in the
>> > contact_us app which renders an existing template.
>> >
>> > Thanks.
>> > --
>> > Regards,
>> > Sithu Lloyd Dube
>> >
>> > --
>> > 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 this group, send email to django-users@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/django-users?hl=en.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>>
>>
>> --
>> Best regards,
>> Andrey Kostakov
>> Email/Gtalk: b...@dzen.ws
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
>
> --
> Regards,
> Sithu Lloyd Dube
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Best regards,
Andrey Kostakov
Email/Gtalk: b...@dzen.ws

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Hi Andrey,

Thanks for the suggestion. I tried that with no success. According to the
current documentation, that would be an issue with versions older than 1.5?
(where one would use url from future).

For some reason, i suspect that the url tag cannot resolve a url for a view
in a "plugged-in" app? (base url + app-view url?).


On Tue, Apr 9, 2013 at 3:40 PM, Andrey Kostakov  wrote:

> Try this without quotes:
> Contact Us
>
> On Tue, Apr 9, 2013 at 5:31 PM, Sithembewena Lloyd Dube
>  wrote:
> > Hi everyone,
> >
> > I have a project based on the latest Django version (1.5.1.) where I
> created
> > a contact_us application. The project has a urls.py file with some url
> > patterns. The contact_us app implements its own urls.py file
> (decoupling).
> > In the project's urls.py file (just above the admin site's url pattern),
> i
> > have the following url pattern:
> >
> > url(r'^contact_us/', include('contact_us.urls', namespace="contact_us")),
> >
> > and in the contact_us app's urls.py file, I have the following url
> pattern:
> >
> > urlpatterns = patterns('',
> > url(r'^$', views.contact_us, name='contact_us'),
> > )
> >
> > In a template residing in the contact_us app's own templates folder, I
> use
> > the url template tag as follows:
> >
> > Contact Us
> >
> > resulting in the following exception:
> >
> > NoReverseMatch at /contact_us/
> >
> > Reverse for 'contact_us' with arguments '()' and keyword arguments '{}'
> not
> > found.
> >
> > Any ideas what I could be missing? I namespaced the contact_us urls
> include
> > in the main urls'py file and there is a simple contact_us view in the
> > contact_us app which renders an existing template.
> >
> > Thanks.
> > --
> > Regards,
> > Sithu Lloyd Dube
> >
> > --
> > 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 this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
>
> --
> Best regards,
> Andrey Kostakov
> Email/Gtalk: b...@dzen.ws
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: {% url %} template tag not resolving app url in template

2013-04-09 Thread Andrey Kostakov
Try this without quotes:
Contact Us

On Tue, Apr 9, 2013 at 5:31 PM, Sithembewena Lloyd Dube
 wrote:
> Hi everyone,
>
> I have a project based on the latest Django version (1.5.1.) where I created
> a contact_us application. The project has a urls.py file with some url
> patterns. The contact_us app implements its own urls.py file (decoupling).
> In the project's urls.py file (just above the admin site's url pattern), i
> have the following url pattern:
>
> url(r'^contact_us/', include('contact_us.urls', namespace="contact_us")),
>
> and in the contact_us app's urls.py file, I have the following url pattern:
>
> urlpatterns = patterns('',
> url(r'^$', views.contact_us, name='contact_us'),
> )
>
> In a template residing in the contact_us app's own templates folder, I use
> the url template tag as follows:
>
> Contact Us
>
> resulting in the following exception:
>
> NoReverseMatch at /contact_us/
>
> Reverse for 'contact_us' with arguments '()' and keyword arguments '{}' not
> found.
>
> Any ideas what I could be missing? I namespaced the contact_us urls include
> in the main urls'py file and there is a simple contact_us view in the
> contact_us app which renders an existing template.
>
> Thanks.
> --
> Regards,
> Sithu Lloyd Dube
>
> --
> 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 this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Best regards,
Andrey Kostakov
Email/Gtalk: b...@dzen.ws

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




{% url %} template tag not resolving app url in template

2013-04-09 Thread Sithembewena Lloyd Dube
Hi everyone,

I have a project based on the latest Django version (1.5.1.) where I
created a contact_us application. The project has a urls.py file with some
url patterns. The contact_us app implements its own urls.py file
(decoupling). In the project's urls.py file (just above the admin site's
url pattern), i have the following url pattern:

url(r'^contact_us/', include('contact_us.urls', namespace="contact_us")),

and in the contact_us app's urls.py file, I have the following url pattern:

urlpatterns = patterns('',
url(r'^$', views.contact_us, name='contact_us'),
)

In a template residing in the contact_us app's own templates folder, I use
the url template tag as follows:

Contact Us

resulting in the following exception:

*NoReverseMatch at /contact_us/*

Reverse for 'contact_us' with arguments '()' and keyword arguments '{}' not
found.

Any ideas what I could be missing? I namespaced the contact_us urls include
in the main urls'py file and there is a simple contact_us view in the
contact_us app which renders an existing template.

Thanks.
-- 
Regards,
Sithu Lloyd Dube

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Bastian
I am trying now in a brand new environment, I have set up a new os, a new 
virtualenv with all the dependencies upgraded to latest versions, and I 
installed the project from the repository. It loads with debug = False, quite 
strange. I need it to work with debug = True and I want to understand what is 
wrong. Thanks for the help. 

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Bastian
I'm not sure what you mean with 'connect to views'. In this case Django is 
complaining about the URL tags, the first one that gives an error tries to load 
django.views.i18n.javascript_catalog. When I manage.py shell I can do from 
django.views import * without problem. 
I really have no clue, maybe it is related to the static files in a way.

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 'url' template tag throws and error after upgrading to 1.4

2013-04-04 Thread Mark Furbee
Can you run manage.py shell and connect to 'views?'


On Thu, Apr 4, 2013 at 4:13 PM, Mark Furbee  wrote:

> It would appear to me that your missing the path to django in your
> environment. When you upgraded did you also upgrade to another version of
> Python, perhaps? Is the dist-packages/site-packages django folder in the
> same place it was?
>
>
> On Thu, Apr 4, 2013 at 3:58 PM, Bastian wrote:
>
>> I have tried with runserver and debug = True and it gives me the error
>> but when I turn off debug then the site loads fine.
>> Then I installed gunicorn and with debug = true and the error appears but
>> with debug = False the site loads fine but without the static content.
>> I don't know if this is a clue about something wrong in the static
>> settings or if it's just a setting in gunicorn.
>>
>> Any idea?
>>
>> --
>> 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 this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

-- 
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 this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




  1   2   3   4   5   6   7   >