1
I’m at the beginning of a project with Django 2.2.1, creating the first apps and making the links between the pages.
In the project’s urls.py, including the Accounts urls worked (with the include(accounts.urls), but when trying to do the same for the expenses app I’m not getting.
When running the runserver, error appears django.core.exceptions.ImproperlyConfigured: The included URLconf 'projeto.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
I have researched and tried several things I found, but nothing is working. If anyone can help I appreciate.
py. of the project
from django.contrib import admin
from django.urls import path, include
from django.views.generic.base import TemplateView
urlpatterns = [
path('admin/', admin.site.urls),
path('expenses/', include('expenses.urls')), # expenses app urls
path('accounts/', include('accounts.urls')), #sign up
path('accounts/', include('django.contrib.auth.urls')), #login and logout
path('', TemplateView.as_view(template_name='home.html'), name='home'), #homepage
]
App files expenses:
py.
from django.urls import path
from . import views
urlpatterns = [
path('create/', views.CreateExpenseView.as_view(template_name='create_expense.html'), name='create-expense'), #create new expense
]
py views.
from django.views.generic.edit import CreateView
from .forms import ExpenseForm
#view for create a new expense
class CreateExpenseView(CreateView):
form_class = ExpenseForm
template_name = 'templates/create_expense.html'
py.models
from django.db import models
class Expense(models.Model):
TYPE = (
('Type1', 'Type1'),
('Type2', 'Type2'),
('Type3', 'Type3'),
('Outros', 'Outros') #abre um campo para digitar
)
type = models.CharField(max_length=10, choices=TYPE, null=True, blank=True)
value = models.FloatField(null=True, blank=True)
num_installments = models.IntegerField(null=True, blank=True) #parcelas
day_installments = models.IntegerField(null=True, blank=True) #dia de pagamento de cada parcela

path('create/', views.CreateExpenseView.as_view(template_name='create_expense.html'), name='create-expense')template_name = 'templates/create_expense.html'would not be better to declare the template only in the url or only in the view?– Davi Wesley
I tried to do it but it didn’t solve :/
– Leila