python - Wrong media location using Django management command -


i'm downloading image , saving models image field, on separate media app. working fine while code in view moved code management command can't image save separate media location. before correctly saving /home/me/webapps/myapp_production_media/images files being saved incorrectly /home/me/webapps/myapp_production_django/src/media/images

command:

download_image('temp', model_instance.image, new_image)  def download_image(name, image, url):     input_file = stringio(urllib2.urlopen(url).read())     output_file = stringio()     img = image.open(input_file)     if img.mode != "rgb":         img = img.convert("rgb")     img.save(output_file, "jpeg")     image.save(name+".jpg", contentfile(output_file.getvalue()), save=false) 

model:

class mymodel(models.model):     image = models.imagefield(upload_to='images', null=true, blank=true) 

i've added myapp_production_media/images path name+".jpg" doesn't change anything. i'm guessing happening because image field in model doesn't access media_root in settings.py (as code management command)?

double-check using same settings file when running management command. production settings not configured default , in these cases need given on command line.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -