Skip to content
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

Open
emieza opened this issue Dec 5, 2014 · 23 comments
Open

Image management in model #8

emieza opened this issue Dec 5, 2014 · 23 comments

Comments

@emieza
Copy link
Member

emieza commented Dec 5, 2014

Add image upload to:

  • FSUser : profile picture
  • FSUser : portrait image
  • Post : attached image

Think about two issues:

  • where to upload and store images
  • how to serve this images in the other views
@moradani
Copy link

12/12/2014

I'll think about it, i'll think about it...

@emieza emieza assigned ghost and unassigned moradani Feb 2, 2015
@ghost
Copy link

ghost commented Feb 2, 2015

Ok! lets code!

@emieza
Copy link
Member Author

emieza commented Feb 2, 2015

One hint to add images to the model:

For the user profile seems reasonable to use Django backend :)

@ghost
Copy link

ghost commented Feb 7, 2015

Finished! (I think...)

@ghost
Copy link

ghost commented Feb 7, 2015

For testing go to /register (register new users), or index (view and create new posts)

@luchinke
Copy link
Contributor

luchinke commented Feb 12, 2015 via email

@ghost
Copy link

ghost commented Feb 12, 2015

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.
for example in latest_posts template:

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

@luchinke
Copy link
Contributor

ty ! Im already installing Pillow. Nice work !

On Thu, Feb 12, 2015 at 11:19 AM, José Pedro Rusakiewicz <
notifications@github.com> wrote:

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.
for example in latest_posts template:

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.


Reply to this email directly or view it on GitHub
#8 (comment).

@ghost
Copy link

ghost commented Feb 12, 2015

why do you need Pillow? I didn't need that!

@luchinke
Copy link
Contributor

Fuck then :/

On Thu, Feb 12, 2015 at 11:27 AM, José Pedro Rusakiewicz <
notifications@github.com> wrote:

why do you need Pillow? I didn't need that!


Reply to this email directly or view it on GitHub
#8 (comment).

@luchinke
Copy link
Contributor

web.FSUser.main_image: (fields.E210) Cannot use ImageField because Pillow
is not installed.
HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip
install pillow".
web.FSUser.profile_image: (fields.E210) Cannot use ImageField because
Pillow is not installed.
HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip
install pillow".
web.Post.image: (fields.E210) Cannot use ImageField because Pillow is not
installed.
HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip
install pillow".

@ghost
Copy link

ghost commented Feb 12, 2015

(0_0) what? are you using django v1.7?

@luchinke
Copy link
Contributor

import django
django.VERSION
(1, 7, 1, 'final', 0)

On Thu, Feb 12, 2015 at 11:31 AM, José Pedro Rusakiewicz <
notifications@github.com> wrote:

(0_0) what? are you using django v1.7?


Reply to this email directly or view it on GitHub
#8 (comment).

@luchinke
Copy link
Contributor

We'll check it later, don' worry.

still ty :)

On Thu, Feb 12, 2015 at 11:36 AM, Lu Chinke lucham1995@gmail.com wrote:

import django
django.VERSION
(1, 7, 1, 'final', 0)

On Thu, Feb 12, 2015 at 11:31 AM, José Pedro Rusakiewicz <
notifications@github.com> wrote:

(0_0) what? are you using django v1.7?


Reply to this email directly or view it on GitHub
#8 (comment).

@ghost
Copy link

ghost commented Feb 12, 2015

Oh sorry! my mistake! I thought it was included by default. yes you have to install pillow.

@luchinke
Copy link
Contributor

Nice. The next question is :

Did you needed to add columns to sqlite for images?

///
Exception Value: no such column: web_post.image

Exception Location:
/home/funky/env/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py
in execute, line 485

On Thu, Feb 12, 2015 at 11:42 AM, José Pedro Rusakiewicz <
notifications@github.com> wrote:

Oh sorry! my mistake! I thought it was included by default. yes you have
to install pillow.


Reply to this email directly or view it on GitHub
#8 (comment).

@ghost
Copy link

ghost commented Feb 12, 2015

nope. did you makemigrations and migrate? before that, I made another push yesterday.

@luchinke
Copy link
Contributor

luchinke commented Feb 12, 2015 via email

@ghost
Copy link

ghost commented Feb 12, 2015

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.

@ghost
Copy link

ghost commented Feb 12, 2015

you don't have to create any directory inside media django will do it for you.

@ghost
Copy link

ghost commented Feb 12, 2015

you can try to delete the sqlite db file and try again with makemigrations and migrate.

@luchinke
Copy link
Contributor

Perfect. Thanks!

On Thu, Feb 12, 2015 at 12:33 PM, José Pedro Rusakiewicz <
notifications@github.com> wrote:

you can try to delete the sqlite db file and try again with makemigrations
and migrate.


Reply to this email directly or view it on GitHub
#8 (comment).

@ghost ghost closed this as completed Feb 13, 2015
@ghost ghost reopened this Mar 6, 2015
@ghost
Copy link

ghost commented Mar 6, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants