Hi, I am new to Django, I read your Tutorial, very interesting and after reading also the tips given, after installation I created the Project.
Below is the structure of the project
I make a summary for clarity. The working folder is called PalestraGes which will have inside it a folder with the same name for the settings of the whole project and the Project folder called Pale
PalestraGes/
PalestraGes
Pale
forms
Pale
Tabelle
RegioniForm.py
static
Pale
css
templates
Pale
Tabelle
RegioniListahtml
views
Pale
Tabelle
RegioniViews.py
__init__.py
admin.py
apps.py
models
urls.py
views.py
The structure is complex but later I will have to make a complex project and I have read that it is good to put the files in different folders
The views.py file I renamed it to viewsPRE.py because it is incopatible with the views folder I created
Based on this structure I tried with a first file.
In models I inserted the fields of the Regioni table.
In urls (of Pale) I inserted the path
# ... importo TABELLE
from Pale/views/Pale/Tabelle/RegioniViews import Regioni
path('RegioniLista/', Regioni, name='RegioniLista'),
In views/Pale/Tabelle/RegioniViews.py
from Pale.models import Regioni
from Pale.forms.Pale.Tabelle import RegioniForm
class RegioniListaView(View):
def regioni_lista(self, request):
Regio = Regioni.objects.all()
return render(request, 'RegioniLista.html', {'Regioni': Regio})
In templates/Pale/Tabelle/RegioniLista.html
{% extends 'base.html' %}
{% block content %}
Pagina delle Regioni
{% endblock %}
From the RegionsList site, I get the error back.
AttributeError at /RegionsList/.
'Regions' object has no attribute 'get'
And I don’t know in which file I got the code wrong.
Sorry if I was long but I preferred to give a complete picture