VisualStudio django.conf.urls
<p>This is my first question ever. I am working in VisualStudio to create a django/python application for smartshopping AI. This is also my first python/django technology application. I have trouble with the urls.py and have read that django versions do not include urlpatterns. I've changed my url patterns to reflect the advice online and have changed my django.conf.urls import url section of my code. It is still not working. Please help.  </p>

<p>I've followed the advices online to get here:</p>

<pre><code>from datetime import datetime
from django.conf.urls import url
from app.forms import BootstrapAuthenticationForm



# Uncomment the next lines to enable the admin:
from django.conf.urls import include
from django.contrib import admin
admin.autodiscover()

urlpatterns = [
    # Examples:
    url(r'^$', 'app.views.home', name='home'),
    url(r'^contact$', 'app.views.contact', name='contact'),
    url(r'^about', 'app.views.about', name='about'),
    url(r'^login/$',
        'django.contrib.auth.views.login',
        {
            'template_name': 'app/login.html',
            'authentication_form': BootstrapAuthenticationForm,
            'extra_context':
            {
                'title':'Log in',
                'year':datetime.now().year,
            }
        },
        name='login'),
    url(r'^logout$',
        'django.contrib.auth.views.logout',
        {
            'next_page': '/',
        },
        name='logout'),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
]
</code></pre>

<p>I want an easy fix not to change all the views to add include - these were autogenerated by visual studio. I want to keep autogeneraton working and just add a line of code to reference the url.py</p>

<pre><code>from django.shortcuts import render
from django.http import HttpRequest
from django.template import RequestContext
from datetime import datetime

def home(request):
    """Renders the home page."""
    assert isinstance(request, HttpRequest)
    return render(
        request,
        'app/index.html',
        context_instance = RequestContext(request,
        {
            'title':'Home Page',
            'year':datetime.now().year,
        })
    )

def contact(request):
    """Renders the contact page."""
    assert isinstance(request, HttpRequest)
    return render(
        request,
        'app/contact.html',
        context_instance = RequestContext(request,
        {
            'title':'Contact',
            'message':'Your contact page.',
            'year':datetime.now().year,
        })
    )

def about(request):
    """Renders the about page."""
    assert isinstance(request, HttpRequest)
    return render(
        request,
        'app/about.html',
        context_instance = RequestContext(request,
        {
            'title':'About',
            'message':'Your application description page.',
            'year':datetime.now().year,
        })
    )
</code></pre>

<p>Based on the responses and the stack overflow answer to a similar question (<a href="http://stackoverflow.com/questions/38744285/django-urls-error-view-must-be-a-callable-or-a-list-tuple-in-the-case-of-includ">Django URLs error: view must be a callable or a list/tuple in the case of include()</a>)  I have tried this approach (which still does not work). </p>

<pre><code>from datetime import datetime
from django.conf.urls import  url
from app.forms import BootstrapAuthenticationForm
from django.contrib.auth import views as auth_views
from SmartShopper import views as SmartShopper_views



# Uncomment the next lines to enable the admin:
# from django.conf.urls import include
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = [
    # Examples:
    url(r'^$', SmartShopper_views.home, name='home'),
    url(r'^contact$', SmartShopper_views.contact, name='contact'),
    url(r'^about', SmartShopper_views.about, name='about'),
    url(r'^login/$',
        'django.contrib.auth.views.login',
        {
            'template_name': 'app/login.html',
            'authentication_form': BootstrapAuthenticationForm,
            'extra_context':
            {
                'title':'Log in',
                'year':datetime.now().year,
            }
        },
        name='login'),
    url(r'^logout$',
        'django.contrib.auth.views.logout',
        {
            'next_page': '/',
        },
        name='logout'),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
</code></pre>

<p>[what my solution contains - I'm coming from an asp.net MVC background and django is a bit different with its MVC type structure still getting used to it, just help me make thisthing run! HELPPP please. thanks <a href="https://i.stack.imgur.com/93SJQ.jpg" rel="nofollow">1</a></p>

<p>You don't need to change your views. The problem is still in your urls.py. Instead of referring to eg <code>"app.views.home"</code> as a string, you need to import the view and refer to <code>views.home</code> directly.</p>

python django django-urls