-1

I really need a lot of help with this and I dont know where to start since I am new to Django so excuse my ignorance.

I'll explain. I am building kind of a image uploading-based page. The images are grouped into albums. I created the album model and the image model which belongs to an album and it has its foreign key. But I dont know how to do the upload itself. I thought I just had to handle the data taken from the template in the views.py file and kind of upload it; but I am getting confused with some things I saw about a form... I dont know. I have no idea.

So its simple: How do I upload the image and register a new row in the database, submitting all the additional data (like pic description) the module requires? Please help with this.

wonderwhy
  • 393
  • 2
  • 19
  • 2
    Define a model with Imagefield and upload_to directory and create model form for the same. – Dheerendra Oct 24 '14 at 20:32
  • @Dheerendra sorry but as i said i am new and I dont know anything about forms and how to use, I have already listened that but as i said I dont know where to start. I would really appreciate a few minutes of your time, please – wonderwhy Oct 24 '14 at 20:53
  • you should read [this](http://www.tangowithdjango.com/book17/chapters/forms.html) chapter from the tangowithdjango book. I hope this will clear your doubts and give you some direction. – Dheerendra Oct 24 '14 at 21:02

1 Answers1

0

Looks like you are confuse about django forms. If you define the forms.py and simply do {{ form }} will render all the field in html so you don't need to worry about defining in html form field. or Don't use form... Define all the field by yourself (!mportant Client side validation is must )

Write the views like save the file into Image Table that's it. If you need anyhelp here . Happy to assist you ..

Raja Simon
  • 10,126
  • 5
  • 43
  • 74
  • thanks, but what's the thing about important client side validation is must? and what code to write to save the image? Thanks though – wonderwhy Oct 25 '14 at 15:36
  • @wonderwhy I did mention client side validation bcse if no `form.py` then the submitted form will hit the server and return error. So that we need `javascript validation`. And you want to save image code ? – Raja Simon Oct 25 '14 at 15:45
  • ah ok. Nah, its ok. I have to try it myself. Thanks. If I have any question I'll ask you. – wonderwhy Oct 26 '14 at 16:31