from django.shortcuts import render
from django.conf import settings
from django.apps import apps


apps_installed = settings.INSTALLED_APPS

# Create your sessions name here
SESSIONS_NAME = [
	"actual_network"
]

# Create your views here.
def index(request):
	template = "hub/index.html"
	context = dict()
	my_apps = list()
	my_models = list()

	for app in apps_installed:
		if "Config" in app:
			my_apps.append(app.split(".")[0])
			app_config = apps.get_app_config(app.split(".")[0])
			tmps = list(app_config.get_models())
			
			my_models = [ str(tmp).split(".")[-1].split("'")[0] for tmp in tmps]
			model_class = apps.get_model("hub", my_models[0])
			print(model_class.objects.filter())
	context["actual_network"] = my_apps[0]
	context["my_apps"] = my_apps
	context["my_models"] = my_models
	return render(request,template,context)

def item_list(request):
	template = "hub/item-list.html"
	context = dict()
	my_apps = list()
	my_models = list()