Coder Social home page Coder Social logo

django-photo-feed's Introduction

Django Interactive Photo Feed

A simple photography feed application I built to practice using Django. The home page is a responsive CSS grid representing the feed of images being rendered from the main_feed collection stored in the SQLite database. The project only consists of a single app, feed.

Users may login or create an account if not registered and may click on images from the main feed to see more details about an image. Users have the option to "like" an image, adding it to their profile's personal liked collection. A running poll of most liked images can be found on the leaderboard page. Admin (superusers) users can access the bundled admin dashboard for performing CRUD operations.

Uploading Images

To upload your own images, make sure your logged into an account with 'superuser' privileges or else the UI won't display in the template as this is currently only an 'admin/superuser' feature. After your logged in, click the 'profile' nav link and scroll down to see two forms: one for adding a single user uploaded (from users filesystem) image, and another for a handling user uploaded CSV files that contains title, src, alt columns for inserting multiple images at a time.

User uploaded content is placed in /media/ within each respective folder files (.csv, .txt) and images (.jpg, .png, .webp etc).

Local setup

  1. Get the code on your computer - Fork this repo and clone it
  2. Perform a migration python3 manage.py migrate
  3. Make migrations python3 manage.py makemigrations
  4. Start dev server python3 manage.py runserver

Database Models

I created two data models Collection and Image aside from the built-in User model. The Image model has two Foreign keys, collection and user. This relationship allows a Collection to be related to multiple images and for images to be related to many different collections. Using ImageField for the user uploaded images and FileField for the uploaded CSV files along with ModelForm.

I opted for this data model structure to keep track of each User records "liked" images by quickly querying all the records in that users associated collection for display on profile pages. A unique collection, ie {name}_{id} is created for new users when they like their first photo or access the profile for the first time and this is the collection that "liked" images from the 'main_feed' collection are added into. This allows for simply adding images into that users associated collection.image_set for a user after the collection is created (if it doesn't already exist), and then increment the votes counter for the image with that id to ensure the public leaderboard updates with the most recent database records.

Each user can have a relationship with a Collection (or many) and multiple different Image objects. Allowing for quick tracking of associated User/Image or Collection/Image records.

Resources

  • Django - Django Documentation
  • Pexels - Provided all stock images used in this application

django-photo-feed's People

Contributors

tannerdolby avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.