Skip to content

Instantly share code, notes, and snippets.

@sgoyal1012
Last active September 23, 2019 08:03
Show Gist options
  • Save sgoyal1012/d1ae11222bc58fa81ebcedf9754dec88 to your computer and use it in GitHub Desktop.
Save sgoyal1012/d1ae11222bc58fa81ebcedf9754dec88 to your computer and use it in GitHub Desktop.
Startup ideas

https://www.youtube.com/watch?v=F5mRW0jo-U4

Minute 14

django-admin

  • python manage.py runserver

Minute 23

settings.py

Minute 30

Apps

  • Apps are components of a Django project, not like the app of a phone
  • createsuperuser to create a user that is the ADMIN
  • contrib.auth and contrib.admin is the app that does this - startapp to create an app
    • Apps should be narrow in focus
  • Create an app --> write the model --> add to apps section in settings.py
  • makemigrations, migrations -- MUST run always when making changes to models.py
  • Register in admin to make the products
  • And le voila! -- You get products in the admin page,

Minute 43

Django shell

  • Create products on the interactive shell

Minute 47

There are so many field types!

  • decimal, text etc.
  • Adding a new field raises questions about its value in the previous rows..
  • Everytime with migrations you get a new migrations file!!

Minute 60 -- Custom homepage

What you see goes in views

  • from django.http import HttpResponse
  • Must route a url to a view in urls.py
  • Can get request info, like request.user

1 Hour, minute 10 -- Django Templates

shortcuts.render

Define your templates and store in a folder

MUST TELL the settings.py file where the templates are!!

1 Hour minute 16 -- Django templating engine

Stuff is shared across templates!! --> Template Inheritance

  • base.html -- extends base.html

1 hour minute 24

Remove redundant code --> e.g navBar to be shared across all pages

1 hour minute 27

Rendering context to a template

  • From a view can pass custom key value pairs to the template
  • Context variables --> the keys become the variables!
  • For loop in a template -- for eg, to enumerate a list
    • {{forloop.counter}}
  • Conditions in a template -- name variables properly!!

1 hour minute 42

Template tags and filters

1 hour minute 49

Render data from the database

  • back to Django shell!
  • Django gives an autoincrementing id field
  • Loads a product from the DB and then sends to template ro render it out
  • Can pass the entire OBJECT -- Awesome!
  • Can have templates inside the sub-app

2 hour 05 mins

Django admin app -- is like our app! Just the admin app

Startup school YCombinator

YH Travel blogger idea!

Finance idea Financial independence

Rushil PhD exercise productization

Whatsapp multimedia search

Find my nightclub!

  • Based on budget, introvert level, music preference, question to answer -->where can I get laid tonight?
  • Girls -- just want to dance, get hit, get complements --
  • Where's the party tonight!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment