django - Is the auto generated photologue image urls overridable? -
i have 2 separate servers. 1 hosting django instance on "www.example.com", other serving static files on "static.example.com". in django settings, media_url points "static.example.com". therefore photologue using "static.example.com" domain.
i want use "www.example.com" photologue, can't figure out how can override media_url setting photologue. know way solve this?
note: django serving on apache, static files hosted on aws (amazon web service). want change photologue domain. other static files must stay are.
unfortunately photologue doesn't provide setting this.
but looking @ code found workaround should trick. assume use get_size_url() methods. of methods call self.cache_url(). so, create subclass of imagemodel (or photo if want have functionality comes it) overrides method.
from photologue.models import imagemodel # or photo class localphoto(imagemodel): # or photo def cache_url(self): local_path = os.path.dirname(self.image.url)[7:].split('/', 1)[1] return '/%s/%s' % (local_path, 'cache') if extended photo have working get_absolute_url() otherwise implementation straight forward.
django admin uses get_admin_thumbnail_url() if define photosize name 'admin_thumbnail' above method should work there too.
effects have method sample_url() used show effect on sample image in django admin. method based on media_url won't work. unfortunately in case cannot override method. since these images won't change upload them aws.
Comments
Post a Comment