Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Deploy django-channels with Apache2 and Daphne
I'm trying to learn to use django-channels and have worked through both the tutorial and this multichat example. I am now trying to deploy it on a Digital Ocean droplet using Apache and Daphne. I would happily use Daphne by itself but I do not understand how to. So this is my Apache conf file: <VirtualHost *:80> ServerAdmin webmaster@mysite.co.uk ServerName multichat.mysite.co.uk ServerAlias www.multichat.mysite.co.uk DocumentRoot /var/www/multichat WSGIDaemonProcess multichat python-path=/var/www/multichat python-home=/var/www/multichat/env WSGIProcessGroup multichat WSGIScriptAlias / /var/www/multichat/multichat/wsgi.py Alias /robots.txt /var/www/multichat/static/robots.txt Alias /favicon.ico /var/www/multichat/static/favicon.ico Alias /media/ /var/www/multichat/media/ Alias /static/ /var/www/multichat/static/ <Directory /var/www/multichat/static> Require all granted </Directory> <Directory /var/www/multichat/media> Require all granted </Directory> WSGIScriptAlias / /var/www/multichat/multichat/wsgi.py <Directory /var/www/multichat/multichat> <Files wsgi.py> Require all granted </Files> </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> I've installed Redis and have it up and running. I've included this file in /etc/systemd/system/daphne.service [Unit] Description=daphne daemon for multichat After=network.target [Service] User=root Group=www-data WorkingDirectory=/var/www/multichat/multichat ExecStart=/var/www/multichat/env/bin/daphne -b 0.0.0.0 -p 8001 multichat.asgi:application # Not sure if should use 'on-failure' or 'always'. Restart=on-failure [Install] WantedBy=multi-user.target Although the webpage comes up and I can login etc, when it comes to a chatroom I have the following error in console: WebSocket connection to 'ws://multichat.mysite.co.uk/chat/stream/' failed: Error during WebSocket handshake: Unexpected response code: 404 I'm clearly not setting up … -
What does the DRF Format option mean
I am using DRF for the first time and I would like to know what the "format" in the following code snippet from their website do: class CommentList(APIView): def get(self, request, format=None): # do stuff... def post(self, request, format=None): # do stuff... I read the docs, but I am not sure how it works still. Can someone enlighten me with an example? Thanks -
Django manifest.json doesn't load icons
I've been trying to figure out how to load the icons from the manifest.json for Django. { "short_name" : "Ct", "name" : "CTAI", "icons" : [ { "src" : "img/black.png", "type" : "image/png", "sizes" : "512x512" } ], "start_url" :"", "background_color" : "#ffffff", "display" : "fullscreen", "theme_color": "#172435", "scope" : "/", "orientation": "potrait" } and also the manifest settings for django in settings.py PWA_APP_NAME = 'Ct' PWA_APP_DESCRIPTION = "The dashboard for all you're needs." PWA_APP_THEME_COLOR = '#172435' PWA_APP_BACKGROUND_COLOR = '#ffffff' PWA_APP_DISPLAY = 'fullscreen' PWA_APP_START_URL = '/' PWA_APP_ICONS = [ { 'src': '/black.png', 'sizes': '512x512' } ] However I get this error. Error while trying to use the following icon from the Manifest: http://127.0.0.1:8000/ (Download error or resource isn't a valid image) In the applications tab of the dev tools, the manifest.json seems to be a bit corrupted. The settings I've given and the settings here are completely different. The dev tools showing the manifest.json Where am I going wrong? -
Get the ID of the object from the selection list. Django, forms
I want to get the ID of my object from the drop down list, how can I do it? is it possible directly? not to use the query set to search for it from the 'cleanded data' method? models.py class Product(models.Model): name = models.CharField(max_length=10) type_product = models.ForeignKey(Type) forms.py class ProductForm(forms.ModelForm): class Meta: model = Time fields = ('type_product' ) views.py data = product_form.cleaned_data['type_product'] # ^ but it does not return id, how to get 'id' object 'Type' from selected option Any help will be appreciated -
How do we archive reports in Django
Am creating an inventory system in Django, the reports are generated monthly and then submitted for archiving. but i have tried most `#views def pay_salary(request): if request.method=="POST": form=SalaryForm(request.POST) if form.is_valid(): form.save() return redirect('salaryreceipt') else: form=SalaryForm() return render(request, 'add_new.html',{'form':form}) -
get_queryset() missing 1 required positional argument: 'country_id'
I have a list of countries they all have there own url www.example.com/al/ for example. But when I want to filter the view per country_id it gives me this error: get_queryset() missing 1 required positional argument: 'country_id' My models class Country(models.Model): COUNTRY_CHOICES = ( ('Albania', 'Albania'), ('Andorra', 'Andorra'), # etc. etc. ) name = models.CharField(max_length=255, choices=COUNTRY_CHOICES, default='Netherlands') def __str__(self): return self.name class City(models.Model): country = models.ForeignKey(Country, on_delete=models.CASCADE) name = models.CharField(max_length=250) def __str__(self): return self.name My Views class CityOverview(generic.ListView): template_name = 'mytemplate.html' def get_queryset(self, country_id, *args, **kwargs): return City.objects.get(pk=country_id) My Urls # Albania path('al', views.CityOverview.as_view(), name='al'), # Andorra path('ad', views.CityOverview.as_view(), name='ad'), # etc. etc. -
Django: Combining search view with Pagination
In a Django CBV (ListView), after submitting a form using GET method, with filter_1 and filter_2 fields, the resulting URL I get is something like: http://example.com/order/advanced-search csrfmiddlewaretoken=12345&filter_1=foo&filter_2=bar Everything is ok. However, I'd like to use pagination, proving to my template a URL like: http://example.com/order/advanced-search csrfmiddlewaretoken=12345&page=2?filter_1=foo&filter_2=bar Let's say I could use override this method for this purpose: def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['my_form_values'] = self.request.GET Now, how can I use my_form_values in my pagination template to display the right URLs? For now, here is my (simplified) pagination template code: {% for num in page_obj.page_range %} {% if page_obj.number == num %} <li class="page-item active"> <span class="page-link">{{ num }}</span> </li> {% else %} <li class="page-item"> <a class="page-link" href="?page={{ num }}">{{ num }}</a> </li> {% endif %} {% endfor %} -
My email link doesn't access to the right path
I have a question about my django settings and nginx in order to display a download link receives in an email generated by a Django view. 1- Context The emailing part works fine. I can receive this one. In this email I created a link which let to download a file stored in MEDIA folder. My issue is about the url generated in the email which works with localhost, but not on my testing environment. 2- My code in my local environment In order to build my download link, I pick up the protocol and domain through : url = self.request.build_absolute_uri(reverse('home')) Then, in my message, I created a link like this : <a href="{{ url }}{% url '<my app>:export_download' token=token %}">Download link to your export file</a> In local, it gives me : http://localhost:8000//download_export/<my_file>/ As you can see, I have a double slashes in my generated url which makes an error. I solved this issue with : url = request.build_absolute_uri('/').strip("/") The urls.py file looks like this : urlpatterns = [ url(r'^home$', HomeView.as_view(), name='home'), ... url(r'^download_export/(?P<token>.*)/$', ExportDownloadView.as_view(), name='export_download'), ] 3- My code in my testing environment In this environment, I'm using nginx as webserver. The application is available from : https://subdomain.domain.fr/dev3/<app_name>/home The … -
Assign objects to specific user in django?
Trying to make my matches.html page show user specific timetable dat however when i log into another user the previous users data is still there. Is there a way i can make the timetable data assigned the user logged in. class timetablesetup(models.Model): module = models.CharField(max_length=150) day = models.CharField(max_length=100) time = models.IntegerField() location = models.CharField(max_length=100) def __str__(self): return self.module Thats my models.py, this is views def matches(request, user): entrys = timetablesetup.objects.all() context = { 'entrys': entrys } return render(request, 'timetableMatch/matches.html', context) def add_entry(request): return render(request, 'timetableMatch/add_entry.html') def delete(request, id): entrys = timetablesetup.objects.get(pk=id) entrys.delete() return redirect('/timetableMatch') def edit(request, id): entrys = timetablesetup.objects.get(pk=id) context = { 'entrys': entrys } return render(request, 'timetableMatch/edit.html', context) def update(request, id): entrys = timetablesetup.objects.get(pk=id) entrys.module = request.GET['module'] entrys.day = request.GET['day'] entrys.time = request.GET['time'] entrys.location = request.GET['location'] try: entrys.save() except Exception: return redirect('/errorpage') else: return redirect('/timetableMatch') and here is my matches page where the time table data is viewed <div class="container"><br> <h2>TimetableMatch</h2> <hr> <table class="table table-dark"> <thead> <tr> <th>Modules</th> <th>Day</th> <th>Time</th> <th>Location</th> <th>Actions</th> </tr> </thead> <tbody> {% for entry in entrys %} <tr> <td>{{ entry.module }}</td> <td>{{ entry.day }}</td> <td>{{ entry.time }}</td> <td>{{ entry.location }}</td> <td><a class="btn btn-info" href="../edit/{{ entry.id }}">Edit</a> <a class="btn btn-danger" href="../delete/{{ entry.id }}">Delete</a> </td> </tr> … -
Django ORM: using combination of F, MAX and GROUP BY
I have the custom model manager, which overrides create method. Target model has order_nbr field, which represents the order of an item. I want to increment the MAX value of order_nbr by one. The key here is that MAX value should be taken in conjuction with GROUP BY. Please, take a look on my code (which still could be affected by race condition): class ContentOnPageModelManager(models.Manager): def create(self, **kwargs): if 'order_nbr' not in kwargs: try: order_nbr = ContentOnPage.objects.filter(page=kwargs['page']).latest('order_nbr').values('order_nbr')[0] except ContentOnPage.DoesNotExist: order_nbr = 0 # TODO (dmitry): race condition kwargs['order_nbr'] = order_nbr + 1 return super().create(**kwargs) class ContentOnPage(models.Model): page = models.ForeignKey('Page', on_delete=models.CASCADE) video = models.ForeignKey('Video', null=True, on_delete=models.SET_NULL) audio = models.ForeignKey('Audio', null=True, on_delete=models.SET_NULL) text = models.ForeignKey('Text', null=True, on_delete=models.SET_NULL) order_nbr = models.PositiveIntegerField(default=0) How can I replace that code with something like: kwargs['order_nbr'] = F(GROUP_BY('page').MAX('order_nbr')) + 1 ^^^ that's more like pseudocode though -
Python passing return variable between functions. Variable referenced before assignment Error [on hold]
I'm trying to pass the variable api after it's parameters have been applied to a function that checks a condition after the params have been applied. When I try to execute the main function which is a shared_task I receive an error. in mb_account_bal api = get_client(api) UnboundLocalError: local variable 'api' referenced before assignment Is this the correct way to pass variables between functions. Why am I receiving this error? from backend.models import MBlogin from celery import shared_task def set_client(): userfield = 'username' passfield = 'password' login_obj = MBlogin.objects.first() username = getattr(login_obj,userfield) password = getattr(login_obj,passfield) api = APIClient(username, password) return api def get_client(api): api = set_client(api) if not api.session_token: api.login() return api @shared_task() def mb_account_bal(): api = get_client(api) r = api.account.get_account(balance_only=True) -
Can I use Django Authentication with Vue
I can use Django Authentication with creating an html file in registration/login.html and it works perfectly fine. But I want to use it with a different front end, Vue, so I just want to call the endpoint /accounts/login, but it throws page does not exist error. How can I overcome this? -
dynamic URL routing in django displaying 'item' on each url
**views.py** from django.shortcuts import render,get_object_or_404 from .models import Product from .forms import ProductForm, RawProductForm # Create your views here. def dynamic_lookup_view(request,id): object=get_object_or_404(Product,id=id) context = { 'object': object } return render (request,"products/product_detail.html",context) **product_detail.html** {% extends '../../base.html' %} {% block content %} <p> {{object.title}} </p> {% endblock %} **urls.py** path('products/<int:id>/',dynamic_lookup_view,name='product'), on changing product id in the browser url it is displaying 'Item' on every product url instead of individual product data. -
Django: Need to request session vars in form
I'm dynamically calling forms from a DB table as I explained in Django Eval from Database. The problem is that I need to call these forms already populated with an instance, this instance for one of my forms must the value of request.session['codEmp'] but Django doesn't allows me to use it in forms. Using it in views would mean to specifically call the difference instance values for every form in the DB. I would need to tell my CompanyConfigutarion form that it has to be populated by default with Company.objects.get(codEmp=request.user['codEmp']). Is there any way to do this? -
PostgreSQL Programming error in Django Query
I have a query as below which returns the grade of all students of a specific class in a specific term(semester) in a specific session(academic year): grades = Grade.objects.filter(term='First', student__in_class=1,session=1).order_by('-total') then another query that annotate through the grades in order to get the sum of the 'total' field. grades_ordered = grades.values('student')\ .annotate(total_mark=Sum('total')) \ .order_by('-total_mark') At first everything works fine until when i migrated from using SQLite to postgreSQL then the following error begins to show up. ERROR: function sum(character varying) does not exist LINE 1: SELECT "sms_grade"."student_id", SUM("sms_grade"."total") AS... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. any help you can provide would be appreciated. thanks -
instance.field.related_model.add(obj) does not work while adding a ManyToManyField on post_save()
I have a Ticket model, one of the fields is tag_map which is a ManyToManyField to Tag model. ticketActionHandler is a handler for signals.post_save built-in signal on Ticket. ticketActionHandler is supposed to assign a Tag object to the Ticket instance. Problem Statement: The Tag object is not set to Ticket instance. Models: class Tag(models.Model): title = models.CharField( max_length=45, blank=False, unique=True, verbose_name=_(u"Tag Name") ) desc = models.CharField( max_length=45, verbose_name=_(u"Tag Description"), blank=True, null=True, ) added_by = models.ForeignKey( settings.AUTH_USER_MODEL, related_name='tagAddedBy' ) modified_time = models.DateTimeField( auto_now_add=True, ) class Meta: db_table = "my_tag" verbose_name = _('Ticket Tag') verbose_name_plural = _('Ticket Tag') def __unicode__(self): return self.title class Ticket(models.Model): #... #... tag_map = models.ManyToManyField( Tag, blank=True ) #... #... def save(self, *args, **kwargs): if not self.id: # This is a new ticket as no ID yet exists. self.created = timezone.now() super(Ticket, self).save(*args, **kwargs) Ticket Handler: @receiver(post_save, sender=Ticket) def ticketActionHandler(sender, instance, **kwargs): print "**********before", instance.tag_map.all() instance.tag_map.add(Tag.objects.get(id=2)) print "**********after", instance.tag_map.all() instance.save() print "**********saved!" More details: While running the same snippet via python manage.py shell works absoltely fine. That is, instance.tag_map.add(Tag.objects.get(id=2)) sets the Tag object to the instance. Attached the generated set of MySQL queries: ********** before < QuerySet [] > (0.002) SELECT helpdesk_tag.id, helpdesk_tag.title, helpdesk_tag.desc, helpdesk_tag.added_by_id, helpdesk_tag.modified_time FROM helpdesk_tag … -
django how to pass object instance to <a href> tag within the modal dialog
In my Django application, I have a delete button to delete a particular file instance. {% for file in file_list %} <tr> <td>{{ file.filename }}</td> <td> <!-- passing the file.pk argument to JS function --> <a data-toggle="modal" href="#fileConfirmDeleteModal" data-id="{{ file.pk }}"> <button>Delete</button> </a> </td> </tr> {% endfor %} In my javascript function call I am displaying the modal confirmation box to delete the file: <script type="text/javascript"> $(document).on("click", ".open-AddBookDialog", function () { var file_pk = $(this).data('id'); //the 'file.pk' instance is retrieved #how to pass 'file_pk' argument to the <a href> tag in the modal $(".modal-body #delete_file_href").val( file_pk ); $('#fileConfirmDeleteModal').modal('show'); }); </script> Below is the Modal dialog which contains a 'Yes' and 'No' button; on clicking 'Yes', a specific url pattern needs to be called i.e. 'delete_file' file.pk <!--Modal: fileConfirmDeleteModal--> <div class="modal fade" id="fileConfirmDeleteModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <!--Content--> <div class="modal-content text-center"> <!--Header--> <p class="heading">Are you sure?</p> <!--Body--> <div class="modal-footer flex-center"> <!--Here I need to append the file.pk value to the 'delete_file url name'--> <a href="{% url 'delete_file' file.pk=file_pk %}" id="delete_file_href"> <button>Yes</button> </a> <a href="" data-dismiss="modal">No</a> </div> </div> <!--/.Content--> </div> </div> On attempting the above code, I encounter the following error: Please help with a suitable solution; I am … -
Djago-suito Object History
I recently install the Django-suit and everything is working fine only the object_history is not working and dont translate my actions and i dont understand why. I already try another framework's like django-jet and everything is working fine only in happens http://prntscr.com/mo4fmc object_history.html {% extends "admin/base_site.html" %} {% load i18n admin_urls %} {% load url from suit_compat %} {% block breadcrumbs %} <div class="breadcrumb"> <li><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a> <span class="divider">&raquo;</span></li> <li><a href="{% url 'admin:app_list' app_label=opts.app_label %}">{% firstof opts.app_config.verbose_name app_label|capfirst|escape %}</a> <span class="divider">&raquo;</span></li> <li><a href="{% url opts|admin_urlname:'changelist' %}">{{ module_name }}</a> <span class="divider">&raquo;</span></li> <li><a href="{% url opts|admin_urlname:'change' object.pk %}">{{ object|truncatewords:"18" }}</a> <span class="divider">&raquo;</span></li> <li class="active">{% trans 'History' %}</li> </div> {% endblock %} {% block content %} <div id="content-main"> <div class="module"> {% if action_list %} <table id="change-history" class="table table-bordered table-condensed table-striped"> <thead> <tr> <th scope="col"><span>{% trans 'Date/time' %}</span></th> <th scope="col"><span>{% trans 'User' %}</span></th> <th scope="col"><span>{% trans 'Action' %}</span></th> </tr> </thead> <tbody> {% for action in action_list %} <tr> <th scope="row">{{ action.action_time|date:"DATETIME_FORMAT" }}</th> <td>{{ action.user.username }}{% if action.user.get_full_name %} ({{ action.user.get_full_name }}){% endif %}</td> <td>{{ action.change_message }}</td> </tr> {% endfor %} </tbody> </table> {% else %} <p>{% trans "This object doesn't have a change history. It probably wasn't added via … -
Add user profile to request.user
I have multiple User Types which I represent by user profiles in the form of a model: Student Teacher I need access to the specific user profile on every request. To avoid executing an extra query every time I would like to add directly a select_related to the request.user object. I couldn't find anything about it in the documentary. Does anyone know the best way to do that? -
DetailSerializer to have listserializer property
I want to add json data from the listserializer to the DetailSerializer class. The serializer looks something like this: serializer.py class ListSerializer(serializers.ModelSerializer): class Meta: model = Fastest_laps fields = '__all__' class DetailSerializer(serializers.ModelSerializer): listserializer = ListSerializer( read_only=True, many=True) class Meta: model = Driver fields = ('place_of_birth','driver','listserializer','picture') But i dont really see the data once i view it, i only see the detailserializer data( Driver model) class Fastest_laps(models.Model): driver_name = models.CharField(max_length=25, null=True) grand_prix = models.CharField(max_length=15, blank=True) car_model = models.CharField(max_length=50) time_taken = models.CharField(blank=True, max_length=8) def __str__(self): return self.driver_name class Driver(models.Model): place_of_birth = models.CharField(max_length=25) driver = models.ForeignKey(Fastest_laps, db_column='driver_name') picture = models.ImageField(blank=True, null=True) def __str__(self): return str(self.driver) -
Trouble with adding rules before deletion of object model
I have two independent models Budget and Conversion as below. class Budget(models.Model): budget = models.FloatField(null=False, blank=False) currency = models.ForeignKey(to=Currency, on_delete=models.PROTECT, null=False, blank=False) date = models.DateField(null=False, blank=False, unique=False) class Conversion(models.Model): currency = models.ForeignKey(to=Currency, on_delete=models.PROTECT, null=False, blank=False) rate = models.FloatField(null=True, blank=False) date = models.DateField(null=False, blank=True, unique=False) I want to add a rule before deletion of object conversion. A conversion should not be delete if there exists a budget who depends from it. There are many posts regarding deletion of django object but I couldn't find an acceptable solution they all have drawbacks. What I tried : Overriding method .delete() and raising a ValidationError -> returns server Error. Implementing a @receiver(pre_delete, sender=Conversion) and raising a ValidationError -> returns server Error Overriding method .clean() didn't get called when using Delete from admin. I would very appreciate a solution that will allow me to prevent user from deleting Conversion objects and without returning a 500 error. Thank you -
How to stop django postgresql timestramp conversion
When I Insert timestamp into Postgres table in EST (2019-02-21 05:37:46) and in Postgresql table is stores in IST (2019-02-21 16:07:46). I want time to be stored only in EST. Can anyone help me to fix this issue? -
Change field required property after form load
I have a form (A), one field of which depends on the select value of the second form (B). So I need that field to become required or not, according to what was selected in the select field of B form. Currently I have the field.required set to False in A form __init__ method, and I check the data from B form in request by overwriting the clean method of A, and make field required if necessary, but that all happens after clicking the submit button. And obviously if the field is now set to required and I change the value of the select field in B, I am no longer able to set field to not required in A, since it simple doesn't let me click submit. Is it possible to make it work somehow? My form: class PublicationCreateForm(forms.ModelForm): class Meta: model = Publication fields = ('title', 'event') def __init__(self, *args, **kwargs): self.request = kwargs.pop('request', None) super(PublicationCreateForm, self).__init__(*args, **kwargs) self.fields['event'].required = False def clean(self): type = self.request.POST['type'] if type == 'BOOK': self.fields['event'].required = False if type == 'CONF': self.fields['event'].required = True -
Using Multiple Annotations in Django
Here is my data base: class User(models.Model): Name = models.TextField(null=True, blank=True, default=None) class Salary(models.Model): value = models.PositiveIntegerField(default=1) name = models.ForeignKey(User, related_name='salarys', on_delete=models.CASCADE) class Expense(models.Model): value = models.PositiveIntegerField(default=1) name = models.ForeignKey(User, related_name='expenses', on_delete=models.CASCADE) I want to add all the salary and expenses of a user. queryset = User.objects.annotate(total_salary=Sum('salarys__value', distinct=True) ,total_expense=Sum('expenses__value', distinct=True)) Here is my data: User table id=1; name= ram Salary table id =1; salary = 12000 id = 2; salary = 8000 Expense table id =1; expense=5000 id=2; expense = 3000 expected output = total_Salary = 20000; total_expense=8000 output obtained : total_salary= 40000; total_expense = 16000 Every output is multiplied the number of times the data in another table. Can anyone help me through this -
Django NoReverseMatch on URL with parameter
I'm having some trouble with an extremely simple form view that posts a single value into the redirect view. Both views work by themselves. It is only this particular view that fails when the form is submitted. views.py def hsk_select(request, username=None): template_name = 'tests/hsklevelselect.html' if request.method == 'POST': form = HskLevelSelectForm(request.POST) if form.is_valid(): level = form.cleaned_data['level'] return redirect('tests:hsktest', level=level) else: form = HskLevelSelectForm() context = { 'form': form, 'username': username, } return render(request, template_name, context) forms.py class HskLevelSelectForm(forms.Form): level = forms.ChoiceField(choices=[(x, x) for x in range(1, 7)]) app/urls.py from django.urls import path from . import views app_name = 'tests' urlpatterns = [ path('duolingo/', views.duolingo_test, name='duotest'), path('hsk/', views.hsk_select, name='hskselect'), path('hsk/<int:level>/', views.hsk_test, name='hsktest'), ] project/urls.py from django.urls import path from . import views app_name = 'main' urlpatterns = [ path('', views.enteruser, name='enteruser'), path('success/', views.success, name='success'), path('<str:username>/', views.home, name='home'), ] Traceback Environment: Request Method: POST Request URL: http://duotool.website.net/username/test/hsk/ Django Version: 2.1.5 Python Version: 3.5.2 Installed Applications: ['rest_framework', 'debug_toolbar', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'main', 'tests', 'widget_tweaks'] Installed Middleware: ['debug_toolbar.middleware.DebugToolbarMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "/var/www/django/duotool.website.net/venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/var/www/django/duotool.website.net/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 126. response = self.process_exception_by_middleware(e, request) File "/var/www/django/duotool.website.net/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 124. response = wrapped_callback(request, …