Re: How to use ImageField??

2012-05-08 Thread Phang Mulianto
you would use MEDIA_URL for calling the image path to be view in  your
template.

and the image will be upload to the media root folder..

On Mon, May 7, 2012 at 8:35 PM, Boris Shemigon  wrote:

> MEDIA_ROOT
>  denotes
> an absolut path where your files are going to be stored.
> MEDIA_URL
>  is
> a relative url to the website's / that handles the media.
>
> For more details please you read the official 
> documentation
> .
>
>
> On Mon, May 7, 2012 at 7:33 PM, Boris Shemigon  wrote:
>
>> MEDIA_ROOTdenotes
>>  an absolut path where your files are going to be stored.
>> MEDIA_URLis
>>  a relative url to the website's / that handles the media.
>>
>> For more details please you read the official 
>> documentation
>> .
>>
>>
>>
>> On Mon, May 7, 2012 at 7:17 PM, atul khairnar wrote:
>>
>>> Hi,
>>> I am writing this ImageViewer app, just to get involved with Django. I
>>> have used *ImageField* to store images in database. I want to load the
>>> images on the clients browser from Django server. But, I think, i can't
>>> distinguish between *media root* and *media url*. I have attached the
>>> project with the mail. Please check the code and help me out. sorry for my
>>> English.
>>>
>>> --
>>> Atul Khairnar
>>> College of Engineering , Pune
>>> Cell - (+91)9579289613
>>>
>>>
>>>  --
>>> 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
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>  --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to use ImageField??

2012-05-07 Thread Boris Shemigon
MEDIA_ROOT
denotes
an absolut path where your files are going to be stored.
MEDIA_URL
is
a relative url to the website's / that handles the media.

For more details please you read the official
documentation
.


On Mon, May 7, 2012 at 7:33 PM, Boris Shemigon  wrote:

> MEDIA_ROOTdenotes
>  an absolut path where your files are going to be stored.
> MEDIA_URLis
>  a relative url to the website's / that handles the media.
>
> For more details please you read the official 
> documentation
> .
>
>
>
> On Mon, May 7, 2012 at 7:17 PM, atul khairnar wrote:
>
>> Hi,
>> I am writing this ImageViewer app, just to get involved with Django. I
>> have used *ImageField* to store images in database. I want to load the
>> images on the clients browser from Django server. But, I think, i can't
>> distinguish between *media root* and *media url*. I have attached the
>> project with the mail. Please check the code and help me out. sorry for my
>> English.
>>
>> --
>> Atul Khairnar
>> College of Engineering , Pune
>> Cell - (+91)9579289613
>>
>>
>>  --
>> 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
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to use ImageField to save images to dynamic path

2008-04-23 Thread PENPEN

I'm not clear how it could be. Could you please explain it in detail?
Many thanks!

/BRs

On Apr 23, 1:34 pm, "Eric Liu" <[EMAIL PROTECTED]> wrote:
> Why don't you set 'images/' as a variant.then you can change it dynamically
>
> 2008/4/23, Rishabh Manocha <[EMAIL PROTECTED]>:
>
>
>
> > Yea, I don't think the method I described would work for directories
> > (or at-least I can't figure out how). It does, however, work if you
> > want to add something to a filename before saving it. The code I use
> > is:
>
> > request.FILES['resume']['filename'] = request.POST['empid'] + "_" +
> > request.FILES['resume']['filename']
>
> > Best,
>
> > R
>
> > On Tue, Apr 22, 2008 at 5:52 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>
> > >  How do you mean of changing request.FILES there itself?
> > >  I tried to add the directory to request.FILES but failed. Django
> > >  ignored the directory and savethe image to the MEDIA_ROOT not
> > >  MEDIA_ROOT/images.
>
> > >  class Thing(models.Model):
> > > photo = models.ImageField(
> > > upload_to='images/', blank=True, null=True)
>
> > > class ThingForm(ModelForm):
> > > class Meta:
> > > model = Thing
>
> > >  def thing_add(request):
> > > if request.method == 'POST':
> > > if 'photo' in request.FILES:
> > > request.FILES['photo']['filename'] =
> > >  ''.join(['test/',request.FILES['photo']['filename']])
> > > form = ThingForm(request.POST, request.FILES)
> > > if form.is_valid():
> > > form.save()
> > > else:
> > > form = ThingForm()
>
> > > return render_to_response('iuv.html', {'form': form})
>
> > >  On Apr 21, 3:19 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
> > >  > I don't know if this answers your specific question, but this is
> > being
> > >  > worked on, apparently -http://code.djangoproject.com/ticket/5361.
>
> > >  > I had a similar requirement, where I wanted to dynamically append a
> > >  > model field to the filename before saving it. I ended up getting the
> > >  > model field's value from request.POST in the view, and changing
> > >  > request.FILES there itself.
>
> > >  > Best,
>
> > >  > R
>
> > > > On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>
> > >  > >  I defined such a model:
>
> > >  > >  class Thing(models.Model):
> > >  > > photo = models.ImageField(
> > >  > >upload_to='images/', blank=True, null=True)
>
> > >  > >  Here is the form for this model:
> > >  > >  class ThingForm(ModelForm):
> > >  > > class Meta:
> > >  > > model = Thing
>
> > >  > >  Now it could handle the image upload request and save images to
> > >  > >  MEDIA_ROOT/images/ directory.
>
> > >  > >  My question is how to change theupload_tovalue dynamicly in the
>
> > > > >  view. For example, I can get the user name in the view level, and I
> > >  > >  want to save the image to that user's directory, e.g. 'avatar/
> > >  > >  username/'.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: How to use ImageField to save images to dynamic path

2008-04-22 Thread Eric Liu
Why don't you set 'images/' as a variant.then you can change it dynamically

2008/4/23, Rishabh Manocha <[EMAIL PROTECTED]>:
>
>
> Yea, I don't think the method I described would work for directories
> (or at-least I can't figure out how). It does, however, work if you
> want to add something to a filename before saving it. The code I use
> is:
>
> request.FILES['resume']['filename'] = request.POST['empid'] + "_" +
> request.FILES['resume']['filename']
>
> Best,
>
> R
>
> On Tue, Apr 22, 2008 at 5:52 PM, PENPEN <[EMAIL PROTECTED]> wrote:
> >
> >  How do you mean of changing request.FILES there itself?
> >  I tried to add the directory to request.FILES but failed. Django
> >  ignored the directory and savethe image to the MEDIA_ROOT not
> >  MEDIA_ROOT/images.
> >
> >
> >  class Thing(models.Model):
> > photo = models.ImageField(
> > upload_to='images/', blank=True, null=True)
> >
> >
> > class ThingForm(ModelForm):
> > class Meta:
> > model = Thing
> >
> >  def thing_add(request):
> > if request.method == 'POST':
> > if 'photo' in request.FILES:
> > request.FILES['photo']['filename'] =
> >  ''.join(['test/',request.FILES['photo']['filename']])
> > form = ThingForm(request.POST, request.FILES)
> > if form.is_valid():
> > form.save()
> > else:
> > form = ThingForm()
> >
> > return render_to_response('iuv.html', {'form': form})
> >
> >
> >
> >  On Apr 21, 3:19 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
> >  > I don't know if this answers your specific question, but this is
> being
> >  > worked on, apparently -http://code.djangoproject.com/ticket/5361.
> >  >
> >  > I had a similar requirement, where I wanted to dynamically append a
> >  > model field to the filename before saving it. I ended up getting the
> >  > model field's value from request.POST in the view, and changing
> >  > request.FILES there itself.
> >  >
> >  > Best,
> >  >
> >  > R
> >  >
> >
> > > On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote:
> >  >
> >  > >  I defined such a model:
> >  >
> >  > >  class Thing(models.Model):
> >  > > photo = models.ImageField(
> >  > >upload_to='images/', blank=True, null=True)
> >  >
> >  > >  Here is the form for this model:
> >  > >  class ThingForm(ModelForm):
> >  > > class Meta:
> >  > > model = Thing
> >  >
> >  > >  Now it could handle the image upload request and save images to
> >  > >  MEDIA_ROOT/images/ directory.
> >  >
> >  > >  My question is how to change theupload_tovalue dynamicly in the
> >
> >
> > > >  view. For example, I can get the user name in the view level, and I
> >  > >  want to save the image to that user's directory, e.g. 'avatar/
> >  > >  username/'.
> >  >
> >
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: How to use ImageField to save images to dynamic path

2008-04-22 Thread Rishabh Manocha

Yea, I don't think the method I described would work for directories
(or at-least I can't figure out how). It does, however, work if you
want to add something to a filename before saving it. The code I use
is:

request.FILES['resume']['filename'] = request.POST['empid'] + "_" +
request.FILES['resume']['filename']

Best,

R

On Tue, Apr 22, 2008 at 5:52 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>
>  How do you mean of changing request.FILES there itself?
>  I tried to add the directory to request.FILES but failed. Django
>  ignored the directory and savethe image to the MEDIA_ROOT not
>  MEDIA_ROOT/images.
>
>
>  class Thing(models.Model):
> photo = models.ImageField(
> upload_to='images/', blank=True, null=True)
>
>
> class ThingForm(ModelForm):
> class Meta:
> model = Thing
>
>  def thing_add(request):
> if request.method == 'POST':
> if 'photo' in request.FILES:
> request.FILES['photo']['filename'] =
>  ''.join(['test/',request.FILES['photo']['filename']])
> form = ThingForm(request.POST, request.FILES)
> if form.is_valid():
> form.save()
> else:
> form = ThingForm()
>
> return render_to_response('iuv.html', {'form': form})
>
>
>
>  On Apr 21, 3:19 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
>  > I don't know if this answers your specific question, but this is being
>  > worked on, apparently -http://code.djangoproject.com/ticket/5361.
>  >
>  > I had a similar requirement, where I wanted to dynamically append a
>  > model field to the filename before saving it. I ended up getting the
>  > model field's value from request.POST in the view, and changing
>  > request.FILES there itself.
>  >
>  > Best,
>  >
>  > R
>  >
>
> > On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>  >
>  > >  I defined such a model:
>  >
>  > >  class Thing(models.Model):
>  > > photo = models.ImageField(
>  > >upload_to='images/', blank=True, null=True)
>  >
>  > >  Here is the form for this model:
>  > >  class ThingForm(ModelForm):
>  > > class Meta:
>  > > model = Thing
>  >
>  > >  Now it could handle the image upload request and save images to
>  > >  MEDIA_ROOT/images/ directory.
>  >
>  > >  My question is how to change theupload_tovalue dynamicly in the
>
>
> > >  view. For example, I can get the user name in the view level, and I
>  > >  want to save the image to that user's directory, e.g. 'avatar/
>  > >  username/'.
>  >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: How to use ImageField to save images to dynamic path

2008-04-22 Thread PENPEN

How do you mean of changing request.FILES there itself?
I tried to add the directory to request.FILES but failed. Django
ignored the directory and savethe image to the MEDIA_ROOT not
MEDIA_ROOT/images.

class Thing(models.Model):
photo = models.ImageField(
upload_to='images/', blank=True, null=True)

class ThingForm(ModelForm):
class Meta:
model = Thing

def thing_add(request):
if request.method == 'POST':
if 'photo' in request.FILES:
request.FILES['photo']['filename'] =
''.join(['test/',request.FILES['photo']['filename']])
form = ThingForm(request.POST, request.FILES)
if form.is_valid():
form.save()
else:
form = ThingForm()

return render_to_response('iuv.html', {'form': form})


On Apr 21, 3:19 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote:
> I don't know if this answers your specific question, but this is being
> worked on, apparently -http://code.djangoproject.com/ticket/5361.
>
> I had a similar requirement, where I wanted to dynamically append a
> model field to the filename before saving it. I ended up getting the
> model field's value from request.POST in the view, and changing
> request.FILES there itself.
>
> Best,
>
> R
>
> On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>
> >  I defined such a model:
>
> >  class Thing(models.Model):
> > photo = models.ImageField(
> >upload_to='images/', blank=True, null=True)
>
> >  Here is the form for this model:
> >  class ThingForm(ModelForm):
> > class Meta:
> > model = Thing
>
> >  Now it could handle the image upload request and save images to
> >  MEDIA_ROOT/images/ directory.
>
> >  My question is how to change theupload_tovalue dynamicly in the
> >  view. For example, I can get the user name in the view level, and I
> >  want to save the image to that user's directory, e.g. 'avatar/
> >  username/'.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: How to use ImageField to save images to dynamic path

2008-04-21 Thread Rishabh Manocha

I don't know if this answers your specific question, but this is being
worked on, apparently - http://code.djangoproject.com/ticket/5361.

I had a similar requirement, where I wanted to dynamically append a
model field to the filename before saving it. I ended up getting the
model field's value from request.POST in the view, and changing
request.FILES there itself.

Best,

R

On Sun, Apr 20, 2008 at 6:45 PM, PENPEN <[EMAIL PROTECTED]> wrote:
>
>  I defined such a model:
>
>  class Thing(models.Model):
> photo = models.ImageField(
> upload_to='images/', blank=True, null=True)
>
>  Here is the form for this model:
>  class ThingForm(ModelForm):
> class Meta:
> model = Thing
>
>  Now it could handle the image upload request and save images to
>  MEDIA_ROOT/images/ directory.
>
>  My question is how to change the upload_to value dynamicly in the
>  view. For example, I can get the user name in the view level, and I
>  want to save the image to that user's directory, e.g. 'avatar/
>  username/'.
>
>  >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to use ImageField to save images to dynamic path

2008-04-20 Thread PENPEN

I defined such a model:

class Thing(models.Model):
photo = models.ImageField(
upload_to='images/', blank=True, null=True)

Here is the form for this model:
class ThingForm(ModelForm):
class Meta:
model = Thing

Now it could handle the image upload request and save images to
MEDIA_ROOT/images/ directory.

My question is how to change the upload_to value dynamicly in the
view. For example, I can get the user name in the view level, and I
want to save the image to that user's directory, e.g. 'avatar/
username/'.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---