I’m creating a new app in django environment. I want to upload image of user when he/she sign-up’s in my app and i want to use the same image when he/she posts any comment in my app. So how to integrate image-uploading code into my app code?
Share
You should be using
UserProfileas has been answered here Django user profile and have the ImageField in there.Then create a
ModelFormfor the UserProfile and render it wherever you want the user to setup their profile and add a user image. The Model form will render the ImageField as a file upload field and have default handles for it. Make sure you haveMEDIA_URLconfigured in yoursettings.py. You would also needPILinstalled in your path for the image upload to work.You can access the
UserProfileinstance for youruserdoinguser.get_profilein your templates and as a callable elsewhere.