Converting basic Python app to Django: How/where to refer to main.py?
I've set up all the foundational pages/folders for a Django app, including a bunch of html templates, admin.py, apps.py, models.py, settings.py, urls.py, views.py, etc. They work fine to pull up the menu.html template without errors. But my main py file, which I call index.py, which has most of my functionality: How and where do I refer to it?
If it helps, here is my views file. Where I am lacking understanding: I'm used to my app starting with main.py and in there calling templates and sending params to those templates.
Django seems to begin with templates and somehow refer back to the many python functions I have in main.py? Here is my views.py file contents:
from django.shortcuts import render
from django.http import HttpResponse
# from psycopg2.extras import DictCursor
# Create your views here.
def index(request):
pages = [
{ 'title': 'User Register', 'slug': 'userRegister' },
{ 'title': 'User Edit', 'slug': 'userEdit' },
{ 'title': 'Show Users', 'slug': 'usersShow' },
{ 'title': 'Show Items', 'slug': 'itemsShow' },
{ 'title': 'Create Item', 'slug': 'itemCreate' },
{ 'title': 'Edit Item', 'slug': 'itemsEdit' },
{ 'title': 'Show Locations', 'slug': 'locationsShow' },
{ 'title': 'Edit Location', 'slug': 'locationEdit' },
{ 'title': 'Edit Category', 'slug': 'catEdit' },
{ 'title': 'Show Categories', 'slug': 'catsShow' },
]
return render(request, 'menu.html',
{
'show_pages': True,
'pages': pages,
},
)
def item_details(request, page_slug):
# called from clearparts/urls.py
selected_page = { 'title': 'Menu', 'description': 'description', 'slug': 'slug' },
return render(request, 'details.html', {
'page_title': selected_page['title'],
'page_description': selected_page['description'],
'page_slug': selected_page['slug'],
}
)
Thanks!