📺 Develpreneur YouTube Episode

Video + transcript

Learn Python And Django Day 46

2021-04-06 •Youtube

Detailed Notes

Part III of the creation of reports. We move into displaying results and a result template.

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

Transcript Text
[Music]
hello and welcome back
we're continuing looking at our django
python series
of our application and we
are deep into reports so we're going to
continue this time
last time around we set it up so we're
able to
basically dynamically create our
parameters
and so what we're going to do this time
around is we're going to actually
run a report now there's a couple ways
we can do this
we could create a url
for each report and we could actually
from run report basically you know turn
around and display some
some results at this point
we're going to do a little differently
so what i want to do instead
because i want to keep it moderately
flexible
so i'm going to do actually i'm just
going to keep it very simple so i'm
going to do rpt
and then i'm going to give it an id
and um
that's a good question how do i want to
do that i think what i want to do here
is i'm going to give it an id
and since for this one these are all
simple
i'm going to give it a parameter
and so that parameter is going to be
also
let's make that a string because each of
these
is well let's see let's look at this
real quick because we can do a couple
different ways
now what we could do is we could post it
and have it try to grab the parameters
which is probably it's really it's the
best way to go about this
as far as being able to uh do things but
let's just do it by
id so whatever we have here
we're gonna have this parameters have an
id and then we'll use that
to get to what we want so we're going to
have an id
for the report let's actually call that
report id
and then we're going to have a pid which
is going to be the parameter
now this does limit us because we're
only going to be able to send
one parameter value per report but for
now we're going to keep it simple
so let's do just report generate
instead of reports page and now that
means we've got to go over to our views
and reports page
we'll just record copy that for now and
he's going to have
the report id and the parameter id
and he's called report generate and now
he's gonna have uh some sort of
his title is gonna be based on
the uh type that we get and so we've got
three
where do we put those so let's just sort
of take this right now
and move this to report generate and so
if
i can do it like this
so for right now uh
title equals
task by timeline
test by roadmap
and test by status
now we're going to use this reports page
so we're actually going to be able to
basically come back to although it's a
slightly different url we're still going
to be able to
you know dynamically make some changes
go in we can look at a report and
quickly
pull another now one other thing we want
to do is let's go back to
uh let's clear a couple of these guys
out and jump to reports page
now what we have here okay so we do have
tasks
and then it's going to list out tasks
based on what we have
uh let's say
we're going to change this
taskless report method ty report
criteria
so it's going to tell us if we don't
have any tasks then so be it now let's
actually do now so
that's our oops this is going to be our
report id
and what we're going to do in each of
these actually is
tasks which we have to send
so we're going to do tasks
and that's going to be tasks and each of
that one
is going to be uh based
on
we have that somewhere so let's do
let's do it like this and steal that
so let's see test equals that
so let's just do this real quick and so
for each of these what we're going to do
is we're going to
filter it based on something so this one
is going to be the timeline which i
think we call it that so we have
timeline roadmap and status
and if we look at our tasks that means
we have oh time
frame we have status
and then road map's going to be actually
up a level so that's going to be a
little different so we're going to do
a time frame
and that's going to be equals tf and
we're going to get that
and our tf is going to be equal to time
line dot objects
dot get where the pk equals
our id
so we're going to filter for that and so
let's actually take the same way
road maps can be a little different so
we're going to do that one
boy how do we want to do that we'll not
deal with that yet
we're going to do that a little bit
funky so we're going to come back to
that so first
let's see status equals
lookup status
dot objects.get so there we go and this
one's going to be the status equals
status
let's let's call it st just to avoid
some confusion
oh do we not have oh i'm sorry it is
time frame
i don't know why i keep wanting to call
it timeline but that's by time frame
let's do it that way
uh and then this one oh it's not
timeline
oh uh time frame equals that time
frame so that's the same thing we're
gonna fix this one on minute first
let's get these two
done so now we're going to do status and
we're going to do
by time frame so if we take those
oh and then run report needs to actually
call that
so run report is going to call
whoops in my url it's going to call this
guy
so we need to go to our reports page
and we do select report let's see where
did we do run report run report run
report does run report so
we don't have him yet so let's create
him
and it's going to do
this and let's go look at what we did
with some of these others
so we're gonna be able to pick up our go
page
and we're gonna use that here except for
what it's going to be
is it's going to be the report whoops
with that plus
our id plus
and then we're going to do the report id
so we're going to call that but first we
have to get those values and those are
going to come
from
so we've got the report and
call it the perimeter i'll call it parm
and so the report is based off of
the report selector
and our parms whoops let's go here i
think those were based off of we called
those
look here that was report parm1
so rpt
capital p parm whoops arm one
and then actually this is going to be
supposed to be report.value
and parm.value
and let's see if this works so if we do
go page
there that should be good if we look
here what we did a go page in the past
it's just because it's included so we
should be set
uh let's see so that should be all good
and it's going to say it can't find that
oh so i could do that global go page so
let's do that just to make it
like that there we go okay
so it's going to run a report and let's
see how that works
so if we come in here and we do this so
let's do we can do by status
and let's do everything that's complete
let's see what happens when we do run
okay so run report undefined complete
we are
it's grabbing the wrong value so let's
take a look at that again so if we look
at our views
uh that's staff my status blah blah blah
blah blah so here we go so
should be each of those should be the
option id
let's take a look at that so if we look
back
oh so we probably don't want value we
actually want
an id
within that so let's look at that real
quick so if we look here
let's look at our page so we do
this okay so text by stat
oops let's do this
and if we do that and that's equal to
complete
and we look
look here
so that's the id
oh that's the id i'm sorry those want to
be values
by mistake so there's a little bit of a
mistake we made there so this
actually wants to be value
value and oh
no i want that to be the id but when i
create the
options i want those to be the values
so let's change that up a little bit um
and then that means i probably want to
fix
that in my report itself
uh where did i put that nope i've got
those values okay so that should be so
report
type oh the select is report type my
mistake i did that again
so that's let's fix that
uh get my id and now let's take a look
at this guy
so come in let's do it by status
complete
run report three three and so now it's
giving us our list
now our list is a little bit uh
interesting and how it's pulling stuff
out
because of how we do this
so we'll take a look at that let's take
a look at our report
real quick
and so for each of these we've got a
time frame
blah blah blah blah we got each of those
we've got a div
and
so that's going to go page let's make
him a row
and see if that works
see if that cleans that up just a little
bit
okay not exactly how we wanted to do it
so let's
tweak that let's go back to where we
were
and since each of these is a car oh
because we
changed the way we did these guys a
little bit ago right
so we've got these and we've got we're
missing a div somewhere in here i think
what we'll see so
let's uh let's not worry about that yet
so if we go by timeline
up let's see let's do that so that was
by there if we go by timeline and we
pick everything that is
first quarter then we're going to only
get the things that are in that time
frame
so we have those two so let's uh wrap
this up a little bit next time what
we're going to do is we'll come around
and we're going to fix
this the status stuff and
we are also going to handle our road map
which is a little more complex
so that'll wrap it up this time we'll
come back and wrap up reports
so go out there until the next time have
yourself a great day
a great week and we will talk to you
next time
you
Transcript Segments
0.63

[Music]

26.16

hello and welcome back

27.84

we're continuing looking at our django

30.16

python series

31.439

of our application and we

34.64

are deep into reports so we're going to

37.52

continue this time

38.64

last time around we set it up so we're

41.52

able to

42.719

basically dynamically create our

45.12

parameters

46.719

and so what we're going to do this time

48.64

around is we're going to actually

50.48

run a report now there's a couple ways

52.559

we can do this

55.28

we could create a url

58.32

for each report and we could actually

61.84

from run report basically you know turn

64.159

around and display some

65.36

some results at this point

68.56

we're going to do a little differently

69.84

so what i want to do instead

71.76

because i want to keep it moderately

74.799

flexible

75.759

so i'm going to do actually i'm just

77.6

going to keep it very simple so i'm

79.28

going to do rpt

81.119

and then i'm going to give it an id

86.64

and um

90.96

that's a good question how do i want to

92.24

do that i think what i want to do here

93.759

is i'm going to give it an id

95.84

and since for this one these are all

98.88

simple

100.079

i'm going to give it a parameter

103.52

and so that parameter is going to be

106

also

109.92

let's make that a string because each of

112.84

these

114.56

is well let's see let's look at this

116.24

real quick because we can do a couple

118.079

different ways

120

now what we could do is we could post it

122.96

and have it try to grab the parameters

124.96

which is probably it's really it's the

127.6

best way to go about this

129.44

as far as being able to uh do things but

131.52

let's just do it by

133.36

id so whatever we have here

137.52

we're gonna have this parameters have an

139.12

id and then we'll use that

141.44

to get to what we want so we're going to

144.4

have an id

146.8

for the report let's actually call that

149.76

report id

150.959

and then we're going to have a pid which

153.2

is going to be the parameter

154.879

now this does limit us because we're

157.76

only going to be able to send

159.28

one parameter value per report but for

162.16

now we're going to keep it simple

164.879

so let's do just report generate

168.239

instead of reports page and now that

170.4

means we've got to go over to our views

173.519

and reports page

179.36

we'll just record copy that for now and

181.519

he's going to have

183.12

the report id and the parameter id

188.159

and he's called report generate and now

198.56

he's gonna have uh some sort of

201.599

his title is gonna be based on

205.36

the uh type that we get and so we've got

208.08

three

208.799

where do we put those so let's just sort

212.239

of take this right now

217.04

and move this to report generate and so

220.239

if

224.799

i can do it like this

228.159

so for right now uh

231.44

title equals

236.48

task by timeline

242.4

test by roadmap

246.64

and test by status

252.56

now we're going to use this reports page

254.48

so we're actually going to be able to

257.44

basically come back to although it's a

259.759

slightly different url we're still going

261.12

to be able to

262

you know dynamically make some changes

264.16

go in we can look at a report and

265.6

quickly

266.16

pull another now one other thing we want

268.72

to do is let's go back to

270.56

uh let's clear a couple of these guys

272.96

out and jump to reports page

275.84

now what we have here okay so we do have

278

tasks

279.919

and then it's going to list out tasks

281.52

based on what we have

283.68

uh let's say

287.919

we're going to change this

293.199

taskless report method ty report

296.16

criteria

297.44

so it's going to tell us if we don't

298.8

have any tasks then so be it now let's

301.44

actually do now so

305.36

that's our oops this is going to be our

307.12

report id

313.44

and what we're going to do in each of

315.28

these actually is

316.56

tasks which we have to send

320

so we're going to do tasks

323.36

and that's going to be tasks and each of

326.72

that one

327.919

is going to be uh based

331.28

on

334.32

we have that somewhere so let's do

339.28

let's do it like this and steal that

353.36

so let's see test equals that

362.319

so let's just do this real quick and so

364.4

for each of these what we're going to do

365.68

is we're going to

367.199

filter it based on something so this one

370.72

is going to be the timeline which i

373.44

think we call it that so we have

374.639

timeline roadmap and status

377.28

and if we look at our tasks that means

380.16

we have oh time

381.36

frame we have status

385.36

and then road map's going to be actually

387.039

up a level so that's going to be a

388

little different so we're going to do

389.759

a time frame

396.24

and that's going to be equals tf and

399.36

we're going to get that

403.84

and our tf is going to be equal to time

407.68

line dot objects

411.52

dot get where the pk equals

415.84

our id

419.759

so we're going to filter for that and so

422.4

let's actually take the same way

423.919

road maps can be a little different so

425.039

we're going to do that one

428.24

boy how do we want to do that we'll not

430.4

deal with that yet

431.52

we're going to do that a little bit

433.12

funky so we're going to come back to

434.24

that so first

435.28

let's see status equals

439.44

lookup status

443.039

dot objects.get so there we go and this

445.28

one's going to be the status equals

448.84

status

451.84

let's let's call it st just to avoid

454.639

some confusion

464.08

oh do we not have oh i'm sorry it is

466.24

time frame

468.16

i don't know why i keep wanting to call

469.52

it timeline but that's by time frame

474

let's do it that way

478.08

uh and then this one oh it's not

480.4

timeline

482.96

oh uh time frame equals that time

486.72

frame so that's the same thing we're

489.599

gonna fix this one on minute first

491.28

let's get these two

494.479

done so now we're going to do status and

498.16

we're going to do

499.199

by time frame so if we take those

502.24

oh and then run report needs to actually

504.56

call that

506.639

so run report is going to call

510.319

whoops in my url it's going to call this

513.039

guy

515.279

so we need to go to our reports page

519.68

and we do select report let's see where

523.039

did we do run report run report run

524.8

report does run report so

529.04

we don't have him yet so let's create

532.839

him

539.44

and it's going to do

547.04

this and let's go look at what we did

548.64

with some of these others

551.76

so we're gonna be able to pick up our go

553.2

page

554.88

and we're gonna use that here except for

558.32

what it's going to be

559.519

is it's going to be the report whoops

563.76

with that plus

568.16

our id plus

573.44

and then we're going to do the report id

577.36

so we're going to call that but first we

578.88

have to get those values and those are

580.72

going to come

581.44

from

585.76

so we've got the report and

593.68

call it the perimeter i'll call it parm

597.519

and so the report is based off of

601.04

the report selector

607.36

and our parms whoops let's go here i

610.32

think those were based off of we called

612.16

those

613.839

look here that was report parm1

619.36

so rpt

622.56

capital p parm whoops arm one

628.32

and then actually this is going to be

634.16

supposed to be report.value

637.519

and parm.value

640.72

and let's see if this works so if we do

642.399

go page

645.279

there that should be good if we look

647.36

here what we did a go page in the past

649.44

it's just because it's included so we

650.959

should be set

654.16

uh let's see so that should be all good

659.279

and it's going to say it can't find that

664.8

oh so i could do that global go page so

667.2

let's do that just to make it

672.399

like that there we go okay

677.279

so it's going to run a report and let's

679.68

see how that works

680.959

so if we come in here and we do this so

683.12

let's do we can do by status

685.6

and let's do everything that's complete

688.32

let's see what happens when we do run

690.64

okay so run report undefined complete

698.399

we are

702

it's grabbing the wrong value so let's

703.519

take a look at that again so if we look

704.88

at our views

708.56

uh that's staff my status blah blah blah

711.12

blah blah so here we go so

713.279

should be each of those should be the

715.6

option id

717.279

let's take a look at that so if we look

719.76

back

728.72

oh so we probably don't want value we

730.72

actually want

732.88

an id

735.92

within that so let's look at that real

737.6

quick so if we look here

740.399

let's look at our page so we do

744

this okay so text by stat

748.16

oops let's do this

751.519

and if we do that and that's equal to

753.12

complete

756.56

and we look

760.959

look here

765.68

so that's the id

770.48

oh that's the id i'm sorry those want to

772.32

be values

774.32

by mistake so there's a little bit of a

776.56

mistake we made there so this

777.92

actually wants to be value

782.32

value and oh

786.399

no i want that to be the id but when i

789.92

create the

790.56

options i want those to be the values

799.12

so let's change that up a little bit um

801.839

and then that means i probably want to

803.12

fix

803.519

that in my report itself

807.12

uh where did i put that nope i've got

808.959

those values okay so that should be so

814.16

report

814.8

type oh the select is report type my

817.12

mistake i did that again

818.399

so that's let's fix that

824.24

uh get my id and now let's take a look

827.76

at this guy

829.44

so come in let's do it by status

832.24

complete

834

run report three three and so now it's

836.8

giving us our list

839.12

now our list is a little bit uh

841.199

interesting and how it's pulling stuff

843.04

out

846.079

because of how we do this

850.32

so we'll take a look at that let's take

851.839

a look at our report

853.44

real quick

856.48

and so for each of these we've got a

858.88

time frame

860.079

blah blah blah blah we got each of those

861.92

we've got a div

863.36

and

866.56

so that's going to go page let's make

870.16

him a row

873.36

and see if that works

880.8

see if that cleans that up just a little

882.839

bit

884.32

okay not exactly how we wanted to do it

887.04

so let's

888.079

tweak that let's go back to where we

890.16

were

894

and since each of these is a car oh

896.399

because we

898.48

changed the way we did these guys a

899.76

little bit ago right

905.68

so we've got these and we've got we're

908.079

missing a div somewhere in here i think

910.16

what we'll see so

913.199

let's uh let's not worry about that yet

915.76

so if we go by timeline

917.199

up let's see let's do that so that was

918.88

by there if we go by timeline and we

920.56

pick everything that is

923.36

first quarter then we're going to only

926.8

get the things that are in that time

928

frame

928.56

so we have those two so let's uh wrap

931.199

this up a little bit next time what

932.24

we're going to do is we'll come around

933.36

and we're going to fix

935.36

this the status stuff and

938.8

we are also going to handle our road map

941.519

which is a little more complex

943.279

so that'll wrap it up this time we'll

944.88

come back and wrap up reports

946.88

so go out there until the next time have

949.04

yourself a great day

950.079

a great week and we will talk to you

953.12

next time

969.519

you