Storing profile-specific images in database
This is my first time designing a web site and I have a question about best-practices. The website we are building has profiles of buildings, and each buildings will have user provided images. Obviously, the images need to 开发者_StackOverflowbe matched up with the buildings.
What is the best way to store this information in a mysql database? Is it as simple as a database table with a primary key for each image, a foreign key for the building, and a path to the image on the server? Is there a better way to do this?
Thanks
Use Djangos ImageField or the model that represents a building. It will store the image on disk, store a path to the image in the database and has all tons of helpers for getting the size, url, etc.
For serving up the image you need to set up your webserver to serve the uploaded images.
精彩评论