Drew Raines wrote:
> Michael Hipp wrote:
> 
> [...]
> 
>> But I have lots of "data" files that live in and around my Django
>> code and I have to access with them with stuff like:
>>
>>     f = open("somedir/myfile.dat", 'r')
>>
>> So how do I make those lines look like that instead of having a bunch of 
>>   absolute paths stuck in there or lots of messy stuff with 
>> os.path.join(os.path.dirname(__file__)...) in it?
> 
> Don't use specific paths throughout your code.  Set variables in
> settings.py and scatter those around.
> 
> To avoid the proliferation of os.path.* everywhere, I use something
> like this in my settings files:
> 
>   import os
>   HOME = os.path.abspath(os.path.dirname(__file__))
> 
>   TEMPLATE_DIRS = (
>       HOME + "/templates",
>   )
> 
>   UPLOADS = HOME + "/files"
> 
> and so on.

Me like. Thanks.

Michael

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to