Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django poll adaptation
I wish make some adjustment on the poll apps https://github.com/divio/django-polls I've got a probleme with the ligne selected_choice = p.choice_set.get(pk=request.POST['choice']) from my views.py because, everything i do, i don't pass the try, and a have every time the exception who is raise. So i don't understand why i don't have my object choice, it's exactlly the same code as the poll tuto. thanks for your help from django.db import models from django.core.validators import MinValueValidator, MaxValueValidator class Question(models.Model): date_creation = models.DateTimeField(auto_now_add=True, auto_now=False, verbose_name="Creation date") date_update = models.DateTimeField(auto_now_add=False, auto_now=True, verbose_name="last change date") auteur = models.CharField(max_length=42, default="Team DEC Attitude") class Qcm(Question): the_qcm_question = models.CharField(max_length=200, default="Question invalide", verbose_name = "QCM Question") def __str__(self): return self.the_qcm_question class Choice(models.Model): qcm = models.ForeignKey(Qcm) choice_text = models.CharField(max_length=200) good_choice = models.BooleanField(default=False) votes = models.IntegerField(default=0)#pour les tests def __str__(self): return self.choice_text my urls.py from django.conf.urls import patterns, url, include from django.views.generic import ListView from django.views.generic import TemplateView from . import views from .models import Qcm urlpatterns = patterns('', url(r'^question_qcm/(?P<qcm_id>\d+)$', views.one_questionnaire, name='url_question_qcm'), url(r'^reponse_qcm/(?P<qcm_id>\d+)$', views.reponse_qcm, name='url_reponse_qcm'), ) my views.py def one_questionnaire(request, qcm_id): try: qcm = Qcm.objects.get(id=qcm_id) except Qcm.DoesNotExist: raise Http404 return render(request, 'questionnaire/qcm_question.html', {'qcm': qcm}) def reponse_qcm(request, qcm_id): p = get_object_or_404(Qcm, pk=qcm_id) try: selected_choice = p.choice_set.get(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): # Redisplay the … -
Checkboxes and Radio buttons in Django ModelForm
Welcome friends, I'm a newbie in Django. I need your help. Seriously. I want to add checkboxes and radio button in my form. I would like to use "Rendering fields manually" too. I know there are Widgets on https://docs.djangoproject.com/en/1.11/ref/forms/widgets/, but I do not know how to use them in practice. Should I change the ModelForm in the Forum. Why? How? Any help will be appreciated. models.py from django.db import models from shop.models import Product class Order(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField() address = models.CharField(max_length=250) postal_code = models.CharField(max_length=20) city = models.CharField(max_length=100) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) paid = models.BooleanField(default=False) class Meta: ordering = ('-created',) def __str__(self): return 'Order {}'.format(self.id) def get_total_cost(self): return sum(item.get_cost() for item in self.items.all()) forms.py from django import forms from .models import Order class OrderCreateForm(forms.ModelForm): class Meta: model = Order fields = ['first_name', 'last_name', 'email', 'address', 'postal_code', 'city'] create.html {% extends "shop/base.html" %} {% block title %} Checkout {% endblock %} {% block content %} <h1>Checkout</h1> <form action="." method="post" class="order-form"> {{ form.as_p }} <p><input type="submit" value="Place order"></p> {% csrf_token %} </form> {% endblock %} Please help. Any suggestions are welcome. -
Django channels sessions
I use Django Channels in combination with a seperate Javascript frontend. Websockets work fine. What I now want to do is: when user opens website, backend generates a specific id. The backends saves that id in the session with message.channel_session['my_id'] on subsequent calls to the backend via the websocket, I want to retreive that key from the session. However, sometimes this seems to work, and sometimes I get a KeyError; my_id does not seem to exist. My code: routing.py: from channels.routing import route from chat.consumers import ws_connect, ws_receive channel_routing = [ route("websocket.connect", ws_connect), route("websocket.receive", ws_receive), ] And consumers.py: import uuid from channels.sessions import channel_session @channel_session def ws_connect(message): message.channel_session['my_id'] = str(uuid.uuid4()) @channel_session def ws_receive(message): my_id = message.channel_session['my_id'] # this one sometimes fails... Any ideas? Is there a race condition or something? -
hosting misago on heroku
I am trying to host the Misago Forum ( a forum framework built on Django)) on Heroku. I followed all the steps given to host a Django app on Heroku. The test worked on the local web but after running 'git push heroku master' it showed something like this When I tried to visit the url Thank you for the help! -
django how to create field dependent field
I have a post model in which i have post type field. I want that when user select post type = assignment this it ask for submission deadline other wise it does not ask anything. and how can i display it in template. models.py class Post(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1) title = models.CharField(max_length=120) slug = models.SlugField(unique=True, blank = True) content = models.TextField() choice = ( ('post','post'), ('anouncement','anouncement'), ('question', 'question'), ('assignment', 'assignment') ) post_type = models.CharField(choices = choice, default = 'post', max_length = 12) classroom = models.ForeignKey(Classroom) updated = models.DateTimeField(auto_now=True, auto_now_add=False) timestamp = models.DateTimeField(auto_now=False, auto_now_add=True) def __unicode__(self): return self.title def __str__(self): return self.title @property def comments(self): instance = self qs = Comment.objects.filter_by_instance(instance) return qs @property def get_content_type(self): instance = self content_type = ContentType.objects.get_for_model(instance.__class__) return content_type def get_absolute_url(self): return reverse("posts:detail", kwargs={"slug": self.slug}) -
HttpResponseRedirect that will redirect you to your second last page
I'd like to ask a questions. is there any way to use HttpResponseRedirect that will redirect you to your second last page. I'm trying to use HttpResponseRedirect(request.META.get('HTTP_REFERER')) however it only redirects me to the last page. -
Can anybody help me in running this Django Python Github Project on windows
The Github link is - https://github.com/pgaspar/Social-Movie-Database Please tell tools and steps to run this project from beginning. -
(Django + External JavaScript) not working
I have a simple project that is using Django 1.11 and Javascript that is not working. When I run the js within the HTML, the json loads and javascripts works, but when I put all of this into the static folder, the javascript loads but nothing is executed. I have configured the static folder and it loads CSS configurations but is not working for javascript. I also run the collectstatics without success. Could you pls help? js: (function(){ 'use strict'; window.onload = function(){ alert("Hi there"));} var SentimientosApp = angular.module('SentimientosApp', []); SentimientosApp.controller('SentimientosCtrl', function ($scope, $http){ $http.get("../externalfiles/countries.json").success(function(data) { $scope.datos = data; }); }); }()); web/sentimientos/index.html: {% load static %} <html ng-app="SentimientosApp"> <head> <meta charset="utf-8"> <title>Angular.js JSON Fetching Example</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <link rel="stylesheet" href="{% static 'css/css.css' %}"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script> <script type="text/javascript" src="{% static 'js/sentimientos.js' %}"></script> </head> {% block content %} <body ng-controller="SentimientosCtrl"> {% block title %}Articles for {{ year }}{% endblock %} <h2>Angular.js JSON Fetching Example</h2> <table> <tr> <th>Code</th> <th>Country</th> <th>Population</th> </tr> <tr ng-repeat="d in datos"> {% verbatim %} <td>{{d.code}}</td> <td>{{d.name}}</td> <td>{{d.population}}</td> <td><input type="text" ng-model="new_title"/>{{ new_title }}</td> {% endverbatim %} </tr> </table> </body> {% endblock %} </html> JSON is located in a folder in statics with this same structure: http://ladimi.com/bigdata/externalfiles/countries.json -
Django Rest Framework: Issue with extended User model and serialization
I' extending the default Django user model to make a customised user profile with additional fields.The following are the related components. models.py class CandidateProfile(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, related_name="user") exp = models.IntegerField(null=True, blank=True) serilaizers.py class CandidateProfileSerializer(serializers.ModelSerializer): id = serializers.IntegerField(source='pk', read_only=True) username = serializers.CharField(source='user.username') email = serializers.CharField(source='user.email') groups = serializers.RelatedField(read_only=True) password = serializers.CharField(max_length=128, source='user.password,read_only=True') class Meta: model = CandidateProfile fields = ('id', 'username', 'password', 'email', 'groups') depth = 1 def update(self, instance, validated_data): print("In Update" + '*' * 50) user = User.objects.get(pk=instance.user.pk) user = instance.user user.email = validated_data.get('user.email', user.email) user.first_name = validated_data.get('user.first_name', user.first_name) user.last_name = validated_data.get('user.last_name', user.last_name) user.save() instance.gender = validated_data.get('gender', instance.gender) instance.save() return instance def create(self, validated_data): print('*' * 100) print(validated_data) user_data = validated_data.pop('user') print(user_data) user = User.objects.create_user(**user_data) g = Group.objects.get(name="Candidate") g.user_set.add(user) user.save() print(validated_data) print('*' * 100) profile = CandidateProfile.objects.create(user=user, **validated_data) return user views.py class CandidateRegister(APIView): def get(self, request, format=None): candidate_list = User.objects.filter(groups=Group.objects.get( name="Candidate")) serializer = CandidateProfileSerializer(candidate_list, many=True) return Response(serializer.data) def post(self, request, format=None): serializer = CandidateProfileSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) I've succcessfully created the user profile as well as the extended Candidate profile.But i'm encoutering an error on doing the same as follows : Got AttributeError when attempting to get a value for … -
How to update one-to-one relationship model?
I have a model that has a one-to-one relationship with the User. I created a form that creates the model, but if that form is submitted again it gives "UNIQUE constraint failed". How can i make it so the data gets updated instead of it trying to create a new one? models.py class Userprofile (models.Model): user = models.OneToOneField(User, related_name='profile', primary_key=True,) address = models.CharField(max_length=100) zip = models.CharField(max_length=100) forms.py class Profile(forms.ModelForm): class Meta: model = Userprofile fields = ['address', 'zip'] views.py def changeprofile(request): form = Profile(request.POST or None, request.FILES or None) if form.is_valid(): profile = form.save(commit=False) profile.user = request.user profile.save() return render(request, 'myaccount.html', {"Profile":form}) -
Django CMS Placeholder Within Template Block Not Displaying
I am following this tutorial on building a basic blog using the Django CMS and am encountering a strange behavior. It all started when I discovered that the Content area was not being created in the Structure section of the CMS. While investigating it, I discovered the strange behavior. Here it is. base.html: <!-- Main Content --> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> {% block content %}{% endblock %} </div> </div> </div> <hr> content.html: {% extends "base.html" %} {% load cms_tags %} {% block content %} {% placeholder content or%} {% endplaceholder %} {% endblock content %} This configuration above displays no Content block on the Structure page of the CMS. However, if I change the base.html snippet to the following, it works. base.html: <!-- Main Content --> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> {% placeholder content or%} {% endplaceholder %} </div> </div> </div> <hr> Could someone tell me why this happens? What am I missing in how Django handles the template blocks? It appears to me that the two cases should be treated identically. Yet, the result is obviously different. The tutorial claims that I should be changing the content.html side. However, as … -
csrf_token of Django into Vuejs when seperate them
I am using ajax request to send POST but it got response 403 because of csrf_token. I divide the frontend just using Vuejs and backend using Django to just reponse API only so I can't use Django template to render {% csrf_token %}. Is there anybody face this problem like me and got some solutions ? So thank you if you can help me this. -
How do use Foreign Key in slug django
My Models: class Faculty(models.Model): name = models.CharField(max_length=30) class Program(models.Model): name = models.CharField(max_length=30) faculty = models.ForeignKey(Faculty) class Student(models.Model): name = models.CharField(max_length=30) slug = models.SlugField(max_length=30, unique=True) faculty = models.ForeignKey(Faculty) program = models.ForeignKey(Program) my Views def profile(request, slug, faculty, program): template_name = 'profile.html' infor = get_object_or_404(Candidate, slug=slug, faculty=faculty, program=program) context = {'title': infor.name} return render(request,template_name,context) Urls url(r'^(?P<faculty>[\w-]+)/(?P<program>[\w-]+)/(?P<slug>[\w-]+)/$', profile, name='profile'), Now I got the profile at host/1/1/sagar-devkota/ what I need is host/science/be/sagar-devkota/ Let assume science is a faculty and be is a program. -
Display JavaScript alert after form submit - Django
Im trying to show an alert if the form submited is valid or not. In the view, I have a hidden input which change the value if form is valid or not. I have this JavaScript: $( document ).ready(function() { if (document.registroForm.alert.value==1){ swal("¡Bien hecho!", "El registro fue exitoso.", "success") } if (document.registroForm.alert.value==0){ swal("¡Oops!", "Algo salió mal.", "error") } }); The problem is that I get the alert every time I refresh the page. And I just wanna do it when the user submit the form and the page is refreshed Thanks. Solved. What I did: views.py def registroUsuario(request): if request.method == "POST": form = registroForm(request.POST or None) if form.is_valid(): alert = 1 instance = form.save(commit=False) instance.is_active = False instance.save() else: alert = 0 else: alert = None form = registroForm() context = { "titulo": "Registrarse", "form": form, "alert": alert, } template = "micuenta/registro.html" return render(request, template, context) and my .html: <form method="POST" action="."> [... some labels and inputs ...] <input type="hidden" name="alert" value="{{alert}}" readonly> </form> <script> $( document ).ready(function() { if (document.registroForm.alert.value==1){ swal("¡Bien hecho!", "El registro fue exitoso.", "success") } if (document.registroForm.alert.value==0){ swal("¡Oops!", "Algo salió mal.", "error") } }); </script> Thanks by the way. -
What does an '_' in django url do?
what does an '_' in django url means like, url(_(r'^mylink/'), include('link5.urls')), _ plus a string should be an error but one public app is using such construct -
Python Django - Uploading a file from the shell
I am trying to upload a file from a shell to one of my django models in the following manner: a = Post(name=name, content=content) a.attachment.save('some.pdf', File(open('some.pdf', 'r'))) But I keep getting the following error: TypeError: must be convertible to a buffer, not FieldFile. I looked at other posts and could not find any solution that solves this problem. I am using Python 2.7 and Django 1.10. I would really appreciate any help. -
django sql translation
I have 2 tables. They are joined by a foreign key relationship. In django, how do i do the equivalent of select col1,col2,col3, table2.* from table1 join table2 on table1.table1id = table2.table2id I am using serializers.serialize and as such values() does not work on the model -
Would posting my code to github affect the security of my application?
background I am writing a simple blog application in Django (data passed through templating language). The owner of the blog will have access to the admin page where they will update the db. Now I understand that in production I will have to hide the security key and turn debug off. question What I am wandering is will pushing the code to github jeopardize the security of the application? -
With Django/Python Open a temp file in memory outside of the function it was created in
I'm having the worst time with this one. In a view I created a csv file that's saved to memory. I need to get that csv file to a utils.py function and post to an external api. I for the life of me can not figure out how to do this and it's really driving me nuts. I originally was just trying to create it in the run_test_suite_in_hatit function below and then somehow open it in the run_all_modal below but that wasn't working. What occurred below was the file (hatit_csv_filename) was now a message object. I don't want to save it to a model as its temporary and is being created purely to be sent right in a api post within HATScript() which is in a utils.py file within the same app in the my project. I'm not sure how to get the file to HATScript() which is just making me nuts. def run_test_suite_in_hatit(request): testrail_suite_id = int(request.GET['suite']) print(testrail_suite_id) testrail_instance = TestRailInstance.objects.first() project = request.user.humanresource.project testrail_project_id = project.testrail.project_id testrail_project = get_testrail_project(testrail_instance, testrail_project_id) testrail_suites = testrail_project.get_suites() testrail_suite = [s for s in testrail_suites if s.id == testrail_suite_id][0] testrail_cases = testrail_suite.get_cases() hatit_csv_filename = bulk_hatit_file_generator(testrail_cases) messages.add_message(request, messages.INFO, hatit_csv_filename) return HttpResponseRedirect('/run_all_modal/') def run_all_modal(request): if request.method … -
RSS aggregator does not update handwritten rss feed
I am working on an RSS server to read Twitter in Feedly (for personal use). I use Django "syndication feed framework" to construct RSS (like shown below). I achieved that RSS is valid (tested with validation), but I can't make Feedly update it properly. То make clear: Feedly is able to find my RSS and also to add it to feed list, but it does not update. I can't understand what mechanism is used by RSS aggregators to get know whether the feed was updated. I can track no http requests from Feedly to my server after the feed was added to list. No requests when I push "refresh" button in Feedly web GUI. The only request the server receives is GET when I am adding the feed. I read that there is "Conditional GET", but it seems that it's not my case: there is no "If-whatever" headers in the request. So the question is: what else should I try to make Feedly update my RSS feed? Thank you in advance! from django.contrib.syndication.views import Feed from django.urls import reverse import tweepy from tweepy import OAuthHandler import datetime consumer_key = '***' consumer_secret = '***' access_token = '***' access_secret = '***' auth … -
What Are The Advantages of Building a Web-Page with Django as Opposed to Solely Using HTML5/CSS3?
Essentially, my questions are as stated above in the title. What I'm really seeking to know is why it would be privy of me to build a web-page utilizing the Django framework as opposed to solely building it out with HTML5 and CSS3. I do know that Django utilizes bootstrapping of HTML5 and CSS and this is where my questions are raised over the efficiency of using the Django framework as opposed to solely using HTML5/CSS3. 1.) What are the advantages of Django? 2.) What does utilizing the Django framework offer me that HTML5/CSS3 do not? 3.) HTML5 can also build dynamic web-pages as can Django. Why would Django be better for a dynamic web-page? I am looking for a very valid answer here as I am about to start building my web-page. The responses I get to these questions will be the nail in the coffin for which method I will be using to build the web-page. Thanks ladies and gentleman and I hope you find this question to be worth your while in answering. -
Making Django & Vue.js work together with {% verbatim %}
I'm trying to make django & Vue work together even though they share the same {{ X }} template syntax. I know that from django 1.5 we can use the {% verbatim %} tag. So I thought I could use django templates as usual and in the section where I need VUE to take over I would just use the {% verbatim %} tag. However instead of loading my vue data django loads the {{ variable }}. For example my django code looks something like this: {% verbatim %} <div id='sessions'> <h2>{{message}}</h2> </div> {% endverbatim %} And in my app.js file I have: var sessions = new Vue({ el: '#sessions', data: { message: 'Hello Vue!' } }) But instead of rendering Hello Vue! it renders {{message}} The console doesn't show any error and vue loads correctly otherwise. How I can make the two work together? Ideally without the need to change the vue.js {{}} syntax. -
Django localhost gives 500 Error Server Error when DEBUG = False, however ALLOWED_HOSTS=['*']
I'm running my Django site on locally, and when DEBUG=True it works fine. However, when I set DEBUG=False, it returns a 500 Server Error. ALLOWED_HOSTS has been set to ['*'], and it still returns a 500 Server Error. Here's my settings.py: import os import dj_database_url # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = "u!*)ik^c1uuptc_iq$hj^o4fmb6b^r%yk((uium3h0!)o+e$4i" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False # Application definition INSTALLED_APPS = [ 'my_app.apps.MyAppConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', # Disable Django's own staticfiles handling in favour of WhiteNoise, for # greater consistency between gunicorn and `./manage.py runserver`. See: # http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development 'whitenoise.runserver_nostatic', 'django.contrib.staticfiles', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'mysite.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], 'debug': DEBUG, }, }, ] WSGI_APPLICATION = 'mysite.wsgi.application' # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'my_db', 'USER': 'admin', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': … -
Json to fullcalendar object
I'm new to using fullcalendar and I cant quite wrap my head around turning the json request to plot on the calendar My model instead of using title, start, end, and all_day Is instead using name, start_date, completion_date, all_day as a result the calendar wont render the objects from my model onto the fullcalendar My views.py is def view_calendar(request): jobs = Job.objects.all() return HttpResponse(events_to_json(jobs), content_type='application/json') THIS IS GENERATING A JSON OBJECT SHOWN AS [{"completionDate": "2015-11-06", "startDate": "2015-11-06", "allDay": false, "name": "342345", "id": 7}, {"completionDate": "2017-04-30", "startDate": "2017-02-19", "allDay": false, "name": "Calendars", "id": 9}, {"completionDate": "2015-02-28", "startDate": "2015-02-26", "allDay": false, "name": "Lowe's Remodel ", "id": 4}, {"completionDate": "2015-02-04", "startDate": "2015-01-18", "allDay": false, "name": "Lowe's Remodel 2", "id": 1}, {"completionDate": "2015-09-13", "startDate": "2015-05-13", "allDay": false, "name": "Lowe's Remodel 3", "id": 5}, {"completionDate": "2017-04-30", "startDate": "2017-04-21", "allDay": false, "name": "WONDER", "id": 10}, {"completionDate": "2015-09-03", "startDate": "2015-08-03", "allDay": false, "name": "aaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd d", "id": 6}, {"completionDate": "2016-04-22", "startDate": "2015-02-24", "allDay": false, "name": "dgfs3344", "id": 3}, {"completionDate": "2015-02-26", "startDate": "2015-02-01", "allDay": false, "name": "gfdgdfs", "id": 2}, {"completionDate": "2015-11-06", "startDate": "2015-11-06", "allDay": false, "name": "ssssgf", "id": 8}] I have no idea how to render this object … -
Cannot import name views from my Project Level Folder
My Django application says that it cannot import the name views in my urls.py file. This I assumed was a problem in the project level file considering Django said: Exception Location: /home/django/django_project/django_project/urls.py in , line 18 However when I navigate to this file I find this: """oop3 URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf import settings from django.conf.urls import url, include from django.conf.urls.static import static from django.contrib import admin urlpatterns = [ # URLS coming in here are sent to the URL file on the ticketr app # url(r'^', include('ticketr.urls')), url(r'^admin/', admin.site.urls), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) No where above does it mention views. The error is coming from line 18 in my urls.py of my application which looks like this """oop3 URL Configuration The `urlpatterns` list …