Re: Settings in Pythoncode

2013-01-09 Thread Stefano Probst
The answer:
I compare my variable with the other setting-variables. All other variables 
are uppercases (-> constant). When I write my variable big, it works.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/odkNeeg6u38J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Settings in Pythoncode

2013-01-09 Thread Daniel Roseman
On Wednesday, 9 January 2013 10:13:27 UTC, Stefano Probst wrote:

> Hi!
> I want to access variables in my code like in the 
> docs.
>  
> I have a code like the following in settings.py:
>
>> codec_baseString = "...XYZ:::"
>>
> In a other file (common.py):
>
>> from django.conf import settings
>> def num2short(num, baseString = settings.codec_baseString):
>> 
>> 
>
> I get the error "'Settings' object has no attribute 'codec_baseString' ". 
> In the docs stand:
>
>> Note that django.conf.settings isn't a module -- it's an object. So 
>> importing individual settings is not possible:
>>
> Refer this sentence to the example after the sentence or to my plan with 
> my own variable?
> Thanks.
>


Your error is probably because the definition is evaluated at import time, 
when the values from settings.py have not yet been added to the 
django.conf.settings object. This would work better:

def num2short(num, base_string=None):
if base_string is None:
base_string = settings.codec_base_string

--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/5OaPAPshRvAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Settings in Pythoncode

2013-01-09 Thread Stefano Probst
Hi!
I want to access variables in my code like in the 
docs.
 
I have a code like the following in settings.py:

> codec_baseString = "...XYZ:::"
>
In a other file (common.py):

> from django.conf import settings
> def num2short(num, baseString = settings.codec_baseString):
> 
> 

I get the error "'Settings' object has no attribute 'codec_baseString' ". 
In the docs stand:

> Note that django.conf.settings isn't a module -- it's an object. So 
> importing individual settings is not possible:
>
Refer this sentence to the example after the sentence or to my plan with my 
own variable?
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Iy_oQkdb8PcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.