user3354539
user3354539

Reputation: 1245

django making methods with variables avaiable from different files

This may be a simple question, but I am really stuck on the issue.

I have been trying to teach myself how to make methods in a views.py file available in other files.

I have a views.py file, where there are several methods like so:

def get_available_language_details(language_versions, user_language_code):
.......

def language_versions_compare(x, y):
.......

def get_language_versions(user):
......

In my education.py file, I realize I must have an import statement from the views.py file, but I don't know how to write the syntax of the import statement as well as the syntax to call the methods above in the education.py file:

import appname.core.views import ??

EDIT
here is my directory structure:

appname
    __init__.py
    core
        __init__.py
        views.py
    views
        __init__.py
        education.py

Upvotes: 0

Views: 22

Answers (1)

utkbansal
utkbansal

Reputation: 2817

from appname.core.views import <function_name>

So it would be something like

from appname.core.views import language_versions_compare

Upvotes: 1

Related Questions