Git Product home page Git Product logo

u4_nostaldja_lab's Introduction

General Assembly Logo

SEIR 118 Feb 2 2022

Nostaldja

Nostaldja is an app for tracking fads across decades.

Prerequisites

  • Python
  • Django
  • Virtual environments

Instructions

  1. Follow the installation instructions
  2. Set up your virtual environment and activate it.
  3. Install dependencies.
  4. Fulfill the listed requirements.

Setup

Read through the setup instructions from our previous labs

The goal of this app is to have a full-CRUD application with multiple views.

Requirements

You'll need to create a new psql database for your app.

Models

Create two models: Decade and Fad.

A Decade will have Fads, or in other words a fad will have a foreign key for a decade.

  • Decades
    • start_year
  • Fads
    • name
    • image_url
    • description
    • decade

Seeding

To seed your database with some initial data, you'll need to create a data migration. Read the documentation on data migrations first, then carefully follow the instructions below.

After you've run makemigrations and migrate, you can then run the following to create a new, empty migration:

python3 manage.py makemigrations --empty nostaldja

Then, paste into the newly generated file the code below:

from django.db import migrations

def seed(apps, schema_editor):
    Fad = apps.get_model('nostaldja', 'Fad')
    Decade = apps.get_model('nostaldja', 'Decade')
    eighties = Decade(start_year="1980s")
    nineties = Decade(start_year="1990s")
    oughts = Decade(start_year="2000s")
    tens = Decade(start_year="2010s")
    eighties.save()
    nineties.save()
    oughts.save()
    tens.save()

    Fad(decade = tens, name='Fidget Spinners', description='A fidget spinner is a toy that consists of a ball bearing in the center of a multi-lobed (typically two or three) flat structure made from metal or plastic designed to spin along its axis with little effort. Fidget spinners became popular toys in April 2017, although similar devices had been invented as early as 1993. ', image_url='https://www.dhresource.com/0x0s/f2-albu-g5-M01-79-07-rBVaJFiuqDSAF3I7AAKBk1FyKy0267.jpg/hand-spinner-fidget-spinner-tri-spinner-diy.jpg').save()
    Fad(decade = tens, name='Block Chain', description='A blockchain, originally block chain, is a continuously growing list of records, called blocks, which are linked and secured using cryptography. Each block typically contains a cryptographic hash of the previous block, a timestamp and transaction data. By design, a blockchain is inherently resistant to modification of the data.', image_url='http://sixpl.com/wp-content/uploads/2017/09/Blockchain-and-Cryptocurrency-Content-Writer.jpg').save()
    Fad(decade = oughts, name='Silly Bandz', description='Silly Bandz are rubber bands made of silicone rubber formed into shapes including animals, objects, numbers, and letters. ', image_url='https://upload.wikimedia.org/wikipedia/commons/thumb/6/69/Silly_Bandz_2009.jpg/2560px-Silly_Bandz_2009.jpg').save()
    Fad(decade = oughts, name='iPods', description='iPhone - Phone = iPod', image_url='https://commons.wikimedia.org/wiki/File:Ipod-touch-1st-gen.jpg').save()
    Fad(decade = oughts, name='Myspace', description='Myspace (stylized as MySpace) is a social networking website offering an interactive, user-submitted network of friends, personal profiles, blogs, groups, photos, music, and videos. Myspace was the largest social networking site in the world, from 2004 to 2010.', image_url='https://us.hellomagazine.com/imagenes/travel/2018012645793/tom-myspace-founder-travel-photographer/0-230-700/myspace-tom-now-t.jpg').save()
    Fad(decade = nineties, name='JNCOs', description='JNCO, short for "Judge None Choose One", is a Los Angeles, California based clothing company specializing in boys\' and men\'s jeans.', image_url='https://img.buzzfeed.com/buzzfeed-static/static/2015-06/23/15/enhanced/webdr08/enhanced-22226-1435087265-4.jpg?downsize=715:*&output-format=auto&output-quality=auto').save()

def fallow(apps, schema_editor):
    Fad = apps.get_model('nostaldja', 'Fad')
    Decade = apps.get_model('nostaldja', 'Decade')
    Decade.objects.all().delete()
    Fad.objects.all().delete()

Then below, add only the line highlighted in green:

class Migration(migrations.Migration):


    dependencies = [
        ('nostaldja', '0006_auto_20180504_1246'),
    ]

    operations = [
+       migrations.RunPython(seed, fallow)
    ]

URLs

Think about the URLs you will need for each resource (Decades and Fads). Hint: both resources will need at least 4 URLs, one for each CRUD action.

Add these URLs to your urls.py file.

Views

Build out some function in your views file to perform actions corresponding to each URL. Again, you'll want full CRUD for each resource.

Templates

Using your URLs and view functions, also build out some templates!

Aside from the base/layout template, you'll want templates like:

Resource Action
Fad Display all
Fad Display detail
Fad Edit detail
Decade Display all
Decade Display detail
Decade Edit detail

Bonus

Implement at least one of the following bonus options by working through the appropriate section of the Django documentation as well as by doing your own research.

Social Authentication

Let's allow users to sign in using their favorite social media app.

Social Authentication is using social media platforms (like Facebook and Twitter) for your authentication. For the remainder of class, work on getting social authentication working (just pick 1 social platform you'd like to use for authentication) using social-auth-app-django.

Use the documentation or this walkthrough.

Image Uploads

Add an image property to the Fad model and read through the documentation on handling file uploads.

Class-based Views

The views we've been writing have been functions, but Django provides the ability to define views as Python classes. Read through the documentation on Class-based views.

Testing

Unit testing is a great way of making sure your code works the way you expect it to. Read through the documentation on testing Django and add tests to your application.

Deployment

How great would it be if you could deploy your app for others to use? Read through the documentation on deploying Django and get your application out there.

Note: If you pick deployment cause you think it's going to be easy (you've already done it before) then you may be in for a surprise. That's not to say that deploying Django applications is especially hard! Just that it wont necessarily be easier.

Plagiarism

Take a moment to refamiliarize yourself with the Plagiarism policy. Plagiarized work will not be accepted.

License

  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

u4_nostaldja_lab's People

Contributors

christopherbowers avatar taubman33 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.