holms
holms

Reputation: 9560

how can I call view method in different files

If I have one view which called myview1.py and I want to call a view which is located in myview2.py, how can I do that?

should I import myview2.py somehow?

Upvotes: 2

Views: 127

Answers (3)

Tauquir
Tauquir

Reputation: 6913

just import it

from myview2 import viewname1, viewname2

value = viewname1(params)

Upvotes: 3

msw
msw

Reputation: 43487

I think you need to read about modules, but here's the cheat sheet:

$ cat gilliam.py
def spam():
    print 'eggs'
$ cat jones.py
import gilliam
gilliam.spam()
$ python jones.py
eggs

Upvotes: 3

brennie
brennie

Reputation: 543

You should be able to just do

import myview2

and be able to access it's methods from there, assuming myview2.py is in your include path.

Upvotes: 2

Related Questions