DEV Community

Matt Dyor
Matt Dyor

Posted on • Updated on

Things I Learned About Python this Week


python manage.py shell

this gets you into an interactive shell

from basic_loans.models import BasicLoan DOES NOT WORK
from dyor_com_app.basic_loans.models import BasicLoanPage
b=BasicLoanPage
from dyor_com_app.base.models import People
p = People
p.first="matt"
p.last="dyor"
bl1 = BasicLoan.objects.filter(id=1).first()
Enter fullscreen mode Exit fullscreen mode

which is the same as:

bl1 = BasicLoan.objects.get(id=1)
bl1.loan_amount
Enter fullscreen mode Exit fullscreen mode

create a record

BL = BasicLoan()
BL.loan_amount
BL.original = bl1
Enter fullscreen mode Exit fullscreen mode

import datetime

BL.loan_start_date = datetime.date(2021, 11, 25)
BL.save()
Enter fullscreen mode Exit fullscreen mode

create an object with inline properties

page = Page.objects.create(title='my title', summary='my summary')
page.__dict__
Enter fullscreen mode Exit fullscreen mode

Top comments (0)