Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

function in django settings?

I would like to add a function to my django settings.py (returning an incremented url).

However, my attempt to add this function is not working...

'Settings' object has no attribute 'nextCdnUrl'

Here is the relevant bits of the settings.py file:

CDN_MIN_I = 1
CDN_MAX_I = 6
CDN_I = CDN_MIN_I

def nextCdnUrl( ):
    CDN_I += 1
    if CDN_I > CDN_MAX_I:
        CDN_I = CDN_MIN_I

    return CDN_BASE_URL.replace( "_i", str(CDN_I) )
like image 851
jedierikb Avatar asked Dec 25 '13 22:12

jedierikb


1 Answers

Settings must be all caps, in this case NEXTCDNURL.

However, it looks like you are trying to alter CDN_I in your function. It's not a good idea to alter settings at runtime.

like image 196
Alasdair Avatar answered Sep 16 '22 13:09

Alasdair