django

How do I display images at different times on webpage

Hello, I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it ...

django mptt and inherited models - not working

Has anyone managed to get django-mptt working with inherited models? After 3 days am close to giving up! If you use abstract this doesn't work because the children can only have parents within the subclass. Tried using normal inheritance and django looks for the parent, lft fields etc. in the child class instead of the parent. Can giv...

"bad character range" exception?

Error: Exception Value: bad character range Exception Location: /usr/lib/python2.6/re.py in _compile, line 245 Python Executable: /usr/bin/python I have absolutely no idea what this means. Can anyone hazard a guess or point me in the right direction? It was all working fine before.. I've only changed a few trivial bits of cod...

How do I memoize expensive calculations on Django model objects?

I have several TextField columns on my UserProfile object which contain JSON objects. I've also defined a setter/getter property for each column which encapsulates the logic for serializing and deserializing the JSON into python datastructures. The nature of this data ensures that it will be accessed many times by view and template logi...

django forms wizard and recaptcha

I did a recaptcha integration using the following django snippet settings.py RECAPTCHA_PUBLIC_KEY = '<your public key>' RECAPTCHA_PRIVATE_KEY = '<your private key>' #widgets.py from django import forms from django.utils.safestring import mark_safe from django.conf import settings from recaptcha import captcha...

Tutorial about how to write custom form fields in django?

Is there any good articles that explain custom form fields in django, not custom model fields? I couldn't find any through google. ...

How to deal with query parameter's encoding?

I assumed that any data being sent to my parameter strings would be utf-8, since that is what my whole site uses throughout. Lo-and-behold I was wrong. For this example has the character ä in utf-8 in the document (from the query string) but proceeds to send a B\xe4ule (which is either ISO-8859-1 or windows 1252) when you click submit. ...

Why is my django template context processor not getting called

I must have missed something in setting up a custom template context as it's never getting called. In settings: TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django_authope...

How to use JQuery and Django (ajax + HttpResponse)?

Suppose I have a AJAX function: function callpage{ $.ajax({ method:"get", url:"/abc/", data:"x="+3 beforeSend:function() {}, success:function(html){ IF HTTPRESPONSE = "1" , ALERT SUCCESS! } }); return false; } } When my "View" executes in Django, I want to return HttpResponse('1') or '0'. How ca...

Python 2.6.2, Django 1.0.3, Windows XP, Page not found: /

I'm just starting to learn Python and Django and an unable to get the most basic app working. I've setup Python, added python to the Path environment variable, installed Django using install.py script. I created an app by running the command django-admin.py startproject my_project updated the settings.py file for a database DATABAS...

Get records before and after current selection in Django query

It sounds like an odd one but it's a really simple idea. I'm trying to make a simple Flickr for a website I'm building. This specific problem comes when I want to show a single photo (from my Photo model) on the page but I also want to show the image before it in the stream and the image after it. If I were only sorting these streams by...

Detect the language & django locale-url

I want to deploy a website in english & spanish and detect the user browser languaje & redirect to the correct locale site. My site is www.elmalabarista.com I install django-localeurl, but I discover that the languaje is not correctly detected. This are my middlewares: MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.Se...

Django ModelForm Validate custom Autocomplete for M2M, instead of ugly Multi-Select

Given the following models (cut down for understanding): class Venue(models.Model): name = models.CharField(unique=True) class Band(models.Model): name = models.CharField(unique=True) class Event(models.Model): name = models.CharField(max_length=50, unique=True) bands = models.ManyToManyField(Band) ven...

Django Vote Up/Down method

I am making a small app that lets users vote items either up or down. I'm using Django (and new to it!). I am just wondering, what is the best way to present the upvote link to the user. As a link, button or something else? I have already done something like this in php with a different framework but I'm not sure if I can do it the sam...

Why can't I save an object in Django?

thechan = Score.objects.filter(content=44)[0:1] thechan[0].custom_score = 2 thechan[0].save() I do print statements, and it shows everything fine. However, it's not SAVING! I go into my database, and I run a simple SELECT statement..and it's not changed! select custom_score FROM music_score where content_id = 44; ...

Can a WIN32 program authenticate into Django authentication system, using MYSQL?

I have a web service with Django Framework. My friend's project is a WIN32 program and also a MS-sql server. The Win32 program currently has a login system that talks to a MS-sql for authentication. However, we would like to INTEGRATE this login system as one. Please answer the 2 things: I want scrap the MS-SQL to use only the Djang...

A way to use method parameters in django templates?

I know there is a post here: http://stackoverflow.com/questions/1333189/django-template-system-calling-a-function-inside-a-model describing how you can make a custom template filter to achieve this, but from a programmer's standpoint this is a failure because that's hacking something that isn't meant for that. It seems almost ridiculous ...

In Django, the HTML code is shown instead of the actual text.

& g t ; Welcome How do I show the actual symbol instead? Is it a template filter? Thanks. ...

Django: apply "same parent" constraint to ManyToManyField mapping to self

I have a model where tasks are pieces of work that each may depend on some number of other tasks to complete before it can start. Tasks are grouped into jobs, and I want to disallow dependencies between jobs. This is the relevant subset of my model: class Job(models.Model): name = models.CharField(max_length=60, unique=True) class ...

Django: ajax response for valid/available username/email during registration

Hello - I am using jQuery to do some inline form validation during user registration to prevent form errors after posting by checking to see if: username is available email has not already been registered The idea is to give the user feedback before the form is submitted to prevent frustration. The code is at the bottom. Question...