📺 Develpreneur YouTube Episode

Video + transcript

Learn Python And Django Day 39

2021-03-11 •Youtube

Detailed Notes

We improve our display of data by using a raw query and pulling in child counts as part of our result set.

You can view source for today and all prior days by reviewing the tag Day 39 at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial

Transcript Text
[Music]
hello
and welcome back we are continuing
um skipping ahead around i guess a
little bit last time we looked at some
css stuff
as i was thinking about it you can get
deep into that quickly
so i'm not going to mess with too much
of the css
i did do a little bit of playing around
and um
we'll have that in the in github if you
want to
see some of this stuff as it kicks into
shape
uh not all of it's actually getting
picked up in my browser right now
there's some caching issue
and i'm not going to actually dive into
it because instead
i want to get to a couple of the other
functions
and one of the things i want to work
through is the idea that we've now got
these
parent-child relationships is to put
something to display those a little
better
starting with road maps so if i go to
road maps i go to annual goals
i have two time frames underneath that
but when i look at my road map
i don't know it so what i want to do is
i'm going to go in
on my roadmaps uh let's see
let me see if i can yes i can close that
terminal i'm going to shut a couple of
these down
so i've got a little more to work with
because i'm going to want my urls which
is here so if i go to roadmap
so i've got list roadmaps and create so
i want list roadmaps
and that's here and when i come through
i'm just pulling road map objects right
now
and what i want to do have we shown
okay i don't think we've actually done a
raw yet so we're going to take a look at
that
or if we did
let me go over here real quick and see
views maybe
no we didn't do it there
so we may not have covered that let's
see did we cover it here
no we did some straight up stuff so okay
so we're going to go do we're going to
look at raw so that's one of the things
that we can do here is instead of
doing a
either all or doing filtered or order by
we can actually do
a dot raw where we're going to do
a full uh i think we're gonna do still
new order by name
except i'm gonna do that within it where
i can actually just send a query back
and i'm gonna get it
but now i'm gonna need to do something
because it's a roadmap
i'm gonna need it to be somewhat similar
to
the roadmap that i had and so what i
need to do here
is i'm going to select from roadmap
i'm going to take a look at my roadmap
model
so here's what i've got
and we're going to do we're going to get
a little bit complicated here but i'm
going to select my name
comma start date
comma so i don't think i even i think i
used time but i wasn't even doing
anything
with it um so i'm gonna do
uh see time frames
which i'm going to actually have to
assign that out
and minutes
from this is
whatever the name of this thing is so
let's go take a look at this in my
sequel real quick i'm gonna do a
terminal
actually i'm gonna do a big terminal
and here
just go there for the fun of it if i go
to my settings
uh where i put my settings here we go
it is uh that's my password
and the user's root
so if i come over here
here so my sql dash you
root dash p
put in my password and now if i see
here you can see where this
is my dp project so i'm going to use
that
and then if i show tables and see all
the tables and the one i'm going to want
is dp project roadmap so let's start
with this
like star
from dp project roadmap and so what i'm
going to see is here's my roadmaps
now i've got the name which is good i
think i'll keep my id so let's put that
here i'm going to select id
and this is from dp project remember we
use the
it's the project name underscore the
name of the model
is the title is the table name uh or you
can look at it the way i did so i'm
gonna do that and then i want to do
order by name
so if i take that it's not going to like
time frames or minutes
so
let's see
so now what i'm going to do is figure
out what what are my time frames and
what are my minutes
now what i can do there is
i actually can go down to my time frames
i'm going to teach a little bit of sql
here
so if i select from time frames and then
i'm going to enter join
and actually let's do this um
well i'm just going to do it this way
and i'm going to call him a map i'm
going to a molar map
at rmp that says good on rmp dot
uh id equals
this guy
called tf i'm gonna keep it star
equals tf dot roadmap id
so now i'm going to see so i can see all
of these and i'm going to
see all these tasks i'm sorry all these
time frames
um so annual personal goals
and then um i can see the
here the name which is the roadmap so it
sort of all sort of blurs together and
actually all of these are on the same
roadmap
which would be easy enough to do so one
of the things i want to do
with this is now
instead of getting anything from the
time frame i'm just gonna get my roadmap
which goes back to
my query here so i want
id names and start date
so but i have to prefix it with the
alias i just used
which is that tf
uh is it not start date
oh i'm sorry not tf it's got to be rmp
my mistake because i'm over here
uh i i a-list out the roadmap
and i want the roadmap information so
i'm going to take the roadmap start date
roadmap name run map id
so if i do that now you see i get just
get that same road map all the time so
now what i need to do
is i can add a groupon group
not groupon but group by um
i'm gonna group by the rmp.id
so now i'm i know that i've got four
tasks here
so now i'm just gonna get one row but
now i need to go get my number of tasks
right so i'm going to get
so i'm going to do here and i just do
count
rmp.id and then i get to cast it as
i'm going to call that as time frames
so now i can see that i've got four time
frames and now if i want to add up the
minutes uh where's the minutes here
which there's probably almost
none oh i'd have to go actually into the
tasks for those so
let's not do that yet
but let's go ahead
and do
and we'll just hard wire it for now so
i'm going to zero as minutes
and so i get that so i'm going to go
ahead and copy and paste
that little raw query
and although it's not going to give me
the same item i have
i'm still going to inner join
oh i didn't copy and paste that right i
don't think
oh let's do it this way there we go
my mistake and i'm going to take this
i don't need the semicolon at the end so
i've got this big thing and i've got my
uh
id name start date time frames so now
i need to change my road map list
uh where that's at that's up here
somewhere so if i go to my roadmap list
now besides all this other stuff that
i've added
yeah see time spent was actually zero
but now that's going to be
[Music]
item.minutes because i'm passing that
back
and uh let's see
i'm gonna say has
and this is gonna be item.time frames
children so now it's got a certain
number of children
and let's just look at it that way so i
save that
and now i see that i've got annual goals
that one has
four children now you can see i
lost my other one there so what i need
to do
is fix my query because
i have an inner join that means only
bring back the ones
the tasks where there's a parent so
instead
i'm not going to make an inner join i'm
going to do a left join actually
yeah i'll say left join
so if i do that and let's look at that
query real quick
if we do that one what we're going to
see over here
whoops i need semicolon is it's getting
all of those so it's grabbing oh because
it's going by tasks
which is a bit of so we need to reverse
it
uh here we go
so here we're doing it from time frames
but we actually need to do it
from the road map
and we're going to join it
on the time frames
and see what happens
oop hey my semicolon and so now i see
that i've got one time frame
because it only counts at once
and so i really need to count the time
frame id
which is uh easy enough to do
so here instead of counting the rnp id
i'm going to count the time frame id
right
and as we come over here let's get this
semicolon and now we see that i get that
and so now if i go to my app
i see that i've got this and i've got my
children so we've been able to
take that parent child into our
interface and that's the next thing
we're going to do is we're going to step
down to the next level
and start looking at sub time frames
and also time time
elapsed or spent on something based on
its task on a time frame based on its
tasks
because once we get down to a task then
or to a time frame then we have tasks
and we're going to be able to work with
those and we're going to do a little
cleaning up here as well because
i'm not being able to see my last item
on there so that'll be our next steps
going to continue digging into this
making this a little easier to deal with
and be able to see more useful
information we go through it and then
start actually walking through the
application and do sort of a
user acceptance test and build out some
tasks so
that's some stuff to look forward to as
always hope you go out there and have
yourself a great day
and we will talk to you oh by the way
this is i believe now
episode 38 that we are
working on um maybe a little further up
that means
let me check that real quick
so this is actually 39 this will be day
39
if you're following along in github take
a look at the
day 39 tag and you'll be able to see the
code that's
here and take it moving forward from
there so
once again have some great day we will
talk to you
next time
you
Transcript Segments
0.63

[Music]

26.24

hello

27.199

and welcome back we are continuing

30.4

um skipping ahead around i guess a

33.04

little bit last time we looked at some

34.239

css stuff

35.92

as i was thinking about it you can get

38.8

deep into that quickly

40.079

so i'm not going to mess with too much

41.92

of the css

43.28

i did do a little bit of playing around

44.96

and um

46.48

we'll have that in the in github if you

49.44

want to

49.92

see some of this stuff as it kicks into

52.399

shape

53.28

uh not all of it's actually getting

55.039

picked up in my browser right now

56.559

there's some caching issue

58.32

and i'm not going to actually dive into

60.48

it because instead

61.76

i want to get to a couple of the other

63.359

functions

65.199

and one of the things i want to work

66.32

through is the idea that we've now got

69.28

these

69.92

parent-child relationships is to put

71.92

something to display those a little

73.92

better

74.88

starting with road maps so if i go to

76.56

road maps i go to annual goals

79.28

i have two time frames underneath that

82

but when i look at my road map

83.36

i don't know it so what i want to do is

86.64

i'm going to go in

87.52

on my roadmaps uh let's see

91.36

let me see if i can yes i can close that

94.56

terminal i'm going to shut a couple of

96

these down

98.4

so i've got a little more to work with

102.799

because i'm going to want my urls which

105.04

is here so if i go to roadmap

108.399

so i've got list roadmaps and create so

110.159

i want list roadmaps

115.28

and that's here and when i come through

119.119

i'm just pulling road map objects right

122.719

now

124.719

and what i want to do have we shown

130.64

okay i don't think we've actually done a

132.239

raw yet so we're going to take a look at

133.76

that

135.2

or if we did

138.72

let me go over here real quick and see

146.879

views maybe

151.04

no we didn't do it there

155.28

so we may not have covered that let's

157.36

see did we cover it here

162.08

no we did some straight up stuff so okay

164.08

so we're going to go do we're going to

165.2

look at raw so that's one of the things

167.44

that we can do here is instead of

170.64

doing a

173.92

either all or doing filtered or order by

176.72

we can actually do

178.879

a dot raw where we're going to do

182

a full uh i think we're gonna do still

184.64

new order by name

186.56

except i'm gonna do that within it where

188.239

i can actually just send a query back

189.84

and i'm gonna get it

191.68

but now i'm gonna need to do something

193.36

because it's a roadmap

194.72

i'm gonna need it to be somewhat similar

197.04

to

198.8

the roadmap that i had and so what i

202.4

need to do here

205.12

is i'm going to select from roadmap

208.56

i'm going to take a look at my roadmap

210.84

model

213.44

so here's what i've got

219.84

and we're going to do we're going to get

221.04

a little bit complicated here but i'm

222.319

going to select my name

224.84

comma start date

227.68

comma so i don't think i even i think i

231.92

used time but i wasn't even doing

233.28

anything

233.76

with it um so i'm gonna do

238.799

uh see time frames

243.2

which i'm going to actually have to

244.64

assign that out

246.239

and minutes

251.68

from this is

255.68

whatever the name of this thing is so

257.04

let's go take a look at this in my

258.56

sequel real quick i'm gonna do a

259.68

terminal

260.88

actually i'm gonna do a big terminal

265.199

and here

268.24

just go there for the fun of it if i go

269.84

to my settings

273.04

uh where i put my settings here we go

277.52

it is uh that's my password

282.4

and the user's root

286.56

so if i come over here

290.32

here so my sql dash you

294.84

root dash p

297.6

put in my password and now if i see

300.639

here you can see where this

303.759

is my dp project so i'm going to use

308.84

that

310.08

and then if i show tables and see all

312.8

the tables and the one i'm going to want

314.479

is dp project roadmap so let's start

317.84

with this

318.4

like star

321.68

from dp project roadmap and so what i'm

324.08

going to see is here's my roadmaps

327.36

now i've got the name which is good i

328.8

think i'll keep my id so let's put that

332.32

here i'm going to select id

337.039

and this is from dp project remember we

340.08

use the

340.72

it's the project name underscore the

342.4

name of the model

344.4

is the title is the table name uh or you

347.12

can look at it the way i did so i'm

348.479

gonna do that and then i want to do

350.8

order by name

354.72

so if i take that it's not going to like

357.68

time frames or minutes

360.4

so

363.6

let's see

367.759

so now what i'm going to do is figure

369.039

out what what are my time frames and

370.479

what are my minutes

373.039

now what i can do there is

378.4

i actually can go down to my time frames

385.039

i'm going to teach a little bit of sql

387.28

here

390.56

so if i select from time frames and then

397.759

i'm going to enter join

401.199

and actually let's do this um

404.56

well i'm just going to do it this way

409.52

and i'm going to call him a map i'm

412.72

going to a molar map

414.8

at rmp that says good on rmp dot

420.4

uh id equals

425.12

this guy

430.24

called tf i'm gonna keep it star

438.24

equals tf dot roadmap id

444

so now i'm going to see so i can see all

447.68

of these and i'm going to

448.96

see all these tasks i'm sorry all these

451.039

time frames

452.56

um so annual personal goals

455.919

and then um i can see the

459.44

here the name which is the roadmap so it

461.36

sort of all sort of blurs together and

463.36

actually all of these are on the same

464.479

roadmap

465.28

which would be easy enough to do so one

467.28

of the things i want to do

470.56

with this is now

478.16

instead of getting anything from the

479.84

time frame i'm just gonna get my roadmap

481.84

which goes back to

485.36

my query here so i want

488.56

id names and start date

496.479

so but i have to prefix it with the

498.96

alias i just used

500.879

which is that tf

506.4

uh is it not start date

512.399

oh i'm sorry not tf it's got to be rmp

516.479

my mistake because i'm over here

520.159

uh i i a-list out the roadmap

523.519

and i want the roadmap information so

525.04

i'm going to take the roadmap start date

528.32

roadmap name run map id

533.2

so if i do that now you see i get just

534.959

get that same road map all the time so

536.48

now what i need to do

539.6

is i can add a groupon group

543.76

not groupon but group by um

546.88

i'm gonna group by the rmp.id

552.32

so now i'm i know that i've got four

554.64

tasks here

556.8

so now i'm just gonna get one row but

558.8

now i need to go get my number of tasks

560.88

right so i'm going to get

567.6

so i'm going to do here and i just do

569.2

count

571.88

rmp.id and then i get to cast it as

575.68

i'm going to call that as time frames

582

so now i can see that i've got four time

583.6

frames and now if i want to add up the

585.839

minutes uh where's the minutes here

588.32

which there's probably almost

589.519

none oh i'd have to go actually into the

591.519

tasks for those so

593.12

let's not do that yet

597.04

but let's go ahead

602.24

and do

607.92

and we'll just hard wire it for now so

609.12

i'm going to zero as minutes

615.04

and so i get that so i'm going to go

616.72

ahead and copy and paste

618.399

that little raw query

626.8

and although it's not going to give me

628.16

the same item i have

630.079

i'm still going to inner join

634.399

oh i didn't copy and paste that right i

636.24

don't think

639.44

oh let's do it this way there we go

645.12

my mistake and i'm going to take this

652.48

i don't need the semicolon at the end so

654.24

i've got this big thing and i've got my

656.16

uh

657.2

id name start date time frames so now

660.32

i need to change my road map list

665.04

uh where that's at that's up here

666.72

somewhere so if i go to my roadmap list

669.839

now besides all this other stuff that

673.12

i've added

674.16

yeah see time spent was actually zero

675.839

but now that's going to be

676.73

[Music]

679.2

item.minutes because i'm passing that

681.36

back

684.64

and uh let's see

690.88

i'm gonna say has

694.32

and this is gonna be item.time frames

700

children so now it's got a certain

701.92

number of children

704.56

and let's just look at it that way so i

706.8

save that

709.519

and now i see that i've got annual goals

711.519

that one has

712.639

four children now you can see i

715.68

lost my other one there so what i need

718.32

to do

719.2

is fix my query because

723.279

i have an inner join that means only

725.2

bring back the ones

726.72

the tasks where there's a parent so

729.68

instead

732

i'm not going to make an inner join i'm

733.76

going to do a left join actually

735.44

yeah i'll say left join

738.48

so if i do that and let's look at that

741.839

query real quick

744.399

if we do that one what we're going to

746

see over here

750.16

whoops i need semicolon is it's getting

753.279

all of those so it's grabbing oh because

755.44

it's going by tasks

758.16

which is a bit of so we need to reverse

761.279

it

764.16

uh here we go

767.2

so here we're doing it from time frames

769.92

but we actually need to do it

771.36

from the road map

777.04

and we're going to join it

781.519

on the time frames

787.04

and see what happens

792

oop hey my semicolon and so now i see

794.8

that i've got one time frame

796.959

because it only counts at once

801.12

and so i really need to count the time

802.639

frame id

804.959

which is uh easy enough to do

809.12

so here instead of counting the rnp id

811.839

i'm going to count the time frame id

815.36

right

820.16

and as we come over here let's get this

823.92

semicolon and now we see that i get that

826.8

and so now if i go to my app

829.12

i see that i've got this and i've got my

830.959

children so we've been able to

834.639

take that parent child into our

836.88

interface and that's the next thing

838.16

we're going to do is we're going to step

839.279

down to the next level

841.12

and start looking at sub time frames

845.36

and also time time

849.04

elapsed or spent on something based on

851.279

its task on a time frame based on its

853.12

tasks

853.92

because once we get down to a task then

856.079

or to a time frame then we have tasks

858.639

and we're going to be able to work with

859.76

those and we're going to do a little

861.04

cleaning up here as well because

862.8

i'm not being able to see my last item

864.399

on there so that'll be our next steps

866.24

going to continue digging into this

868.56

making this a little easier to deal with

870.8

and be able to see more useful

872.399

information we go through it and then

873.76

start actually walking through the

874.959

application and do sort of a

876.88

user acceptance test and build out some

879.199

tasks so

880.399

that's some stuff to look forward to as

882.399

always hope you go out there and have

883.76

yourself a great day

885.12

and we will talk to you oh by the way

887.199

this is i believe now

888.56

episode 38 that we are

892.16

working on um maybe a little further up

895.519

that means

896.24

let me check that real quick

899.76

so this is actually 39 this will be day

902.24

39

903.279

if you're following along in github take

905.519

a look at the

906.88

day 39 tag and you'll be able to see the

909.839

code that's

910.8

here and take it moving forward from

913.44

there so

914.399

once again have some great day we will

916.56

talk to you

917.76

next time

933.759

you