Diagnosing AttributeError in Django view

In a Django project of mine, I've written simple webhook logic that pings a url for certain payload if some condition is met. Here's the code: @csrf_exempt def webhook_event(request,*args,**kwargs): if request.method == 'POST': data = js...
more »

2017-05-21 22:05 (1) Answers

Django base translation file is not used?

I have a Django project and would like to use i18n to have support of diferent languages. In my template I write: {% load i18n l10n %} <span>{% trans 'Sun' %}</span> then I create required directories inside my BASE_DIR: ./locale/LC_M...
more »

2017-05-21 21:05 (0) Answers

Django time convert format

I am trying to convert time into specific format using following code: datetime.datetime.strptime(timezone.now() + timedelta(days=14), '%Y-%m-%dT%H:%M:%S.%f%z') I am getting error that the first parameter has to be string. I also tried using this...
more »

2017-05-21 16:05 (2) Answers

template does not exist at /(given url)

It worked on localhost, but in production it is showing this error: TemplateDoesNotExist at /tcapp/tcpage app/urls.py from django.conf.urls import url from .import views urlpatterns = [ url(r'^tcapp/tcpage', views.tcpage, name='tcpage'), ...
more »

2017-05-21 16:05 (2) Answers

Somehow import Django object inside a js script

I would like to access a django object inside a js script. In other words, I want the output of {{ contract.request.customer.fax }} with something like var fax = {{ contract.request.customer.fax }}, but it did not work. My code is not being rendere...
more »

2017-05-20 23:05 (0) Answers

Django - Multiprocess Queue Not Updating

I am trying to update two values of a queue at the same time, but my code ends up in an infinite loop. I'm running it on Django View, the code below runs well but when I try it on Django it just keeps waiting. What could be happening? import multipr...
more »

2017-05-20 15:05 (0) Answers

INNER JOIN with DJANGO framework

Two weeks I try to make a JOIN with django class Groupe(models.Model): nomgroupe = models.CharField(max_length=50) def __str__(self): return self.nomgroupe class Album(models.Model): code = models.CharField(max_length=50) nomgrou...
more »

2017-05-20 13:05 (1) Answers

Wagtail per page user permission

My task is to enable users to edit their own page. I see how to give permissions to a particular page to a group, but how do I do this for the user? I'd tried use django guardian: UserObjectPermission.objects.assign_perm('change_custompage', user...
more »

2017-05-19 23:05 (2) Answers

Bootstrap CSS - Info Box Alignment

I have the following bootstrap info box: <div class="alert alert-info" style="text-align: center" role="info"> <span style="font-size: 30px; vertical-align: middle; padding:0px 10px 0px 0px;" class="glyphicon glyphicon-inf...
more »

2017-05-19 14:05 (2) Answers

Django Noreverse Error for below code

I'm trying to set search navbar to work on my website but I keep getting this error which I do not to decode. I'm using django 1.8 on Python 2.7 My template html file is below. <div id="navbar" class="navbar-collapse collapse"> <ul class=...
more »

2017-05-18 14:05 (2) Answers

Python dependency issues with Django on Docker

Im new to Docker and im having troubles porting my already existing and working Django project to Docker and im pretty much stuck right now since the issue is with the dependencies in my requirements.txt that are frozen and actually are working on my...
more »

2017-05-18 09:05 (0) Answers

List Django urlpatterns in Sphinx docs

I'm using sphinx to document my django app. Using sphinx-apidoc I created documentation for the whole app application, but I need to add urlpatterns from app.urls to the documentation. Currently docs for this module contain only its name, and I want ...
more »

2017-05-17 18:05 (0) Answers

Django QuerySet filter ValueError not caught?

I am trying to filter a Django QuerySet. I know that sometimes the filter terms will be invalid. In this case, I want to catch the error. Here is a silly contrived example: models.py: from uuid import uuid4 from django.db import models class My...
more »

2017-05-17 17:05 (2) Answers