On 3/6/07, samira <[EMAIL PROTECTED]> wrote: > > Mybe I didn't describe good. this is my project: I want to have user > page that get member information and allow user to upload her display > image. I don't know how I can do this,. > Here is a example:
1. settings.py MEDIA_ROOT = 'media/' 2. template <form enctype="multipart/form-data" action="/user/{{ person.id }}/edit/" method="post" id="user_edit"> <input type="file" name="photo"/> </form> 3. model class UserProfile(models.Model): portrait = models.ImageField(_('Photo'), upload_to='photo', blank=True) user = models.ForeignKey(User, unique=True) You can see there is a upload_to parameter, so the real image will be save in : os.path.join(MEDIA_ROOT, field.upload_to) 4. view snippet #get or create user if data.get('photo', None): filename = 'photo_%d.jpg' % user.id user.save_photo_file(filename, data['photo']['content'] user.save() -- I like python! UliPad <<The Python Editor>>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---