I have a few apps within my Django project and all of them seem to be working, except for the User app. All the apps are installed in the settings. Whenever I type "python manage.py runserver", I see a long line of code that ends with this:
File "/Users/Name/Desktop/Project_Name/MyProject/User/urls.py", line 5,
in <module>
url(r'Home/', views.User, name='Home'),
AttributeError: module 'User.views' has no attribute 'User'
MyProject/urls.py
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', include('Home.urls')),
url(r'^Application', include('Application.urls')),
url(r'^Login', include('Login.urls')),
url(r'^User', include('User.urls')),
]
User/urls.py
from django.conf.urls import url, include
from User import views
urlpatterns = [
url(r'Home/', views.User, name='Home'),
url(r'Matrices/', views.User, name='Matrices'),
]
User/views.py
from django.shortcuts import render
def Home(request):
return render(request, 'Home.html')
def Matrices(request):
return render(request, 'Matrices.html')
If I remove "url(r'^User', include('User.urls'))" from MyProjects/urls.py, everything is working fine (but of course I cannot access the urls from User app). All the other apps have only one "url" and only User app has multiple urls. Is that where the issue lies?
Would greatly appreciate any help. Thanks!
user/views.py has no method User, you have only two methods HOME and MATRICES, and you are trying to call a method named User doing this `
url(r'Matrices/', views.User, name='Matrices')
To solve your problem you need call an available method from user/views.py HOME or MATRICES like this
url(r'ThisIsTheNameOfTheUrlNotTheMethod/', views.Home, name='Home'),
or
url(r'matrices/', views.Matrices, name='Matrices'),
Your urlpatterns needs to use the views.py functions like
urlpatterns = [
url(r'Home/$', views.Home, name='Home'),
url(r'Matrices/$', views.Matrices, name='Matrices'),
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With