Skip to content

Instantly share code, notes, and snippets.

@abhisuri97
Created November 27, 2017 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhisuri97/3c9e67189a01b7a224ac7e8bf7dda7ac to your computer and use it in GitHub Desktop.
Save abhisuri97/3c9e67189a01b7a224ac7e8bf7dda7ac to your computer and use it in GitHub Desktop.
Importing environment from .env file
SECRET KEY ENV VAR NOT SET! SHOULD NOT SEE IN PRODUCTION
THIS APP IS IN DEBUG MODE. YOU SHOULD NOT SEE THIS IN PRODUCTION.
>>> from app import models, db
>>> club = models.Club(name="hello world club")
>>> category1 = models.ClubCategory(category_name="test1")
>>> category2 = models.ClubCategory(category_name="test2")
>>> club2 = models.Club(name="hello world club 2")
>>> club.categories.append(category1)
>>> club.categories.append(category2)
>>> category1.clubs.append(club2)
>>> [x.category_name for x in club.categories]
['test1', 'test2']
>>> [x.category_name for x in club2.categories]
['test1']
>>> [x.name for x in category1.clubs]
['hello world club', 'hello world club 2']
>>> [x.name for x in category2.clubs]
['hello world club']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment