-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image management in model #8
Comments
12/12/2014 I'll think about it, i'll think about it... |
Ok! lets code! |
One hint to add images to the model:
For the user profile seems reasonable to use Django backend :) |
Finished! (I think...) |
For testing go to /register (register new users), or index (view and create new posts) |
I would like to know how an image is stored in django (which directory) to
do the src tag in the posts template !
|
you only have to create a new directory under /web named media. You don't have to specify the whole path in the src attribute to the image in the html code, django will do it for us. <img src='{{MEDIA_URL}}{{post.image}}' width=40%> the MEDIA URL is configured in the settings file ('/media/') and post.image will be a folder inside /media named /user_images (you don't have to create it). you can try it in your development environment. |
ty ! Im already installing Pillow. Nice work ! On Thu, Feb 12, 2015 at 11:19 AM, José Pedro Rusakiewicz <
|
why do you need Pillow? I didn't need that! |
Fuck then :/ On Thu, Feb 12, 2015 at 11:27 AM, José Pedro Rusakiewicz <
|
|
(0_0) what? are you using django v1.7? |
On Thu, Feb 12, 2015 at 11:31 AM, José Pedro Rusakiewicz <
|
We'll check it later, don' worry. still ty :) On Thu, Feb 12, 2015 at 11:36 AM, Lu Chinke lucham1995@gmail.com wrote:
|
Oh sorry! my mistake! I thought it was included by default. yes you have to install pillow. |
Nice. The next question is : Did you needed to add columns to sqlite for images? /// Exception Location: On Thu, Feb 12, 2015 at 11:42 AM, José Pedro Rusakiewicz <
|
nope. did you makemigrations and migrate? before that, I made another push yesterday. |
Saw it. I updated all today. You forgot an upload_path on Posts. I defined
this one as 'posts_images' and created the directory inside media.
Ill keep trying with makemigatrions.
|
here's the post model in the last push i made: class Post(models.Model):
upload_path = 'users_images' i'ts working for me. you can look that in https://github.com/lacetans/faceschool/blob/image/web/models.py allusers images (posts, profile and wall) are saved in users_images. |
you don't have to create any directory inside media django will do it for you. |
you can try to delete the sqlite db file and try again with makemigrations and migrate. |
Perfect. Thanks! On Thu, Feb 12, 2015 at 12:33 PM, José Pedro Rusakiewicz <
|
Problema detectat!! després d'enviar un formulari de post, si l'usuari refresca la pàgina es torna a eviar el formulari creant posts duplicats!!! He estat buscant i he trobat això: http://en.wikipedia.org/wiki/Post/Redirect/Get Ho hauríem d'implementar en Django |
Add image upload to:
Think about two issues:
The text was updated successfully, but these errors were encountered: