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

How to check if you are in a Jupyter notebook

I am creating a python module with a function to display a pandas DataFrame (my_df). If the user imports the module into a Jupyter notebook, I would want to deliver "pretty" formatting for the DataFrame by using something like: from IPython.display...
more »

2017-05-21 20: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

Why does sys.getrefcount give huge values?

import sys a = 10 b = a print sys.getrefcount(a) b=1 print sys.getrefcount(b) output: 22 614 Is there any problem with my python interpreter? Why is this giving huge values like 614? Python version /usr/lib/python2.7/ ...
more »

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

In memory SQLite3 shared database python

I am trying to make the best out of an aws server and had the idea to use an in memory database across multiple threads(using SQLite 3 in python) I found this command online: conn = sqlite3.connect('file::memory:?cache=shared') but then I get ...
more »

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

Minimax algorithm for Tic Tac Toe Python

I kind of understand how the minimax algorithm works for Tic Tac Toe python but I have no idea how to actually code it in Python... this is what I have so far: from copy import deepcopy class TicTacToeBrain : def __init__(self, player = "x") :...
more »

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

CreditCard Checker

I'm actually trying to write a tool,it's supposed to show which one number is correct in the txt file. All Numbers in my file a correct but it still say "Number Invalid". here is the code: #!/usr/bin/python #coding: utf-8 import requests import ite...
more »

2017-05-20 17: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

How to pre-process a very large data in python

I have a couple of files 100 MB each. The format for those files looks like this: 0 1 2 5 8 67 9 122 1 4 5 2 5 8 0 2 1 5 6 ..... (note the actual file does not have the alignment spaces added in, only one space separates each eleme...
more »

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

Problems assigning variables to SQLite Tuples

First off, I apologize if this seems elementary, I am fairly new to python and very new to SQlite. I also apologize for the wall of text, but I have gotten so much help from this site, that maybe someone else can learn from this issue as well. I hav...
more »

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

Update MySQL database with Python 3

I'm trying to insert data from python into a MySQL database I made with phpmyadmin. I'm using Python 3. This doesn't seem to update my database - what's happening here? import MySQLdb db = MySQLdb.connect("localhost", "uname", "password", "HORSERAC...
more »

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