django

Multiple database support in django.

From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet. Can anyone please tell me how one can achieve multiple database connections in Django. Does anyone have any idea by when Django will fully/officially support Multiple database connections. ...

How can you emulate a mailing list in Django?

I'm on a project which is trying to write what amounts to a Mailing List app in Django, and we're running into a couple of problems/questions. The code we have so far doesn't set various List headers, and re-sets the To header to be the person we're sending it to, instead of the list address. Now, we can work our way through all these ...

Django - How to do tuple unpacking in a template 'for' loop

In my views.py, I'm building a list of two-tuples, where the second item in the tuple is another list, like this: [ Product_Type_1, [ product_1, product_2 ], Product_Type_2, [ product_3, product_4 ]] In plain old Python, I could iteration the list like this: for product_type, products in list: print product_type for product...

How does one add default (hidden) values to form templates in Django?

Given a Django.db models class: class P(models.Model): type = models.ForeignKey(Type) # Type is another models.Model class name = models.CharField() where one wishes to create a new P with a specified type, i.e. how does one make "type" to be a default, hidden field (from the user), where type is given likeso: http://x.y/P/new?...

User Authentication in Django

Hi, is there any way of making sure that, one user is logged in only once? I would like to avoid two different persons logging into the system with the same login/password. I guess I could do it myself by checking in the django_session table before logging in the user, but I rather prefer using the framework, if there is already such f...

UTF-8 latin-1 conversion issues, python django

ok so my issue is i have the string '\222\222\223\225' which is stored as latin-1 in the db. What I get from django (by printing it) is the following string, 'ââââ¢' which I assume is the UTF conversion of it. Now I need to pass the string into a function that does this operation: strdecryptedPassword + chr(ord(c) - 3 - intCounter -...

How do I list items in my Django models?

Am working with django Publisher example, I want to list all the publishers in the db via my list_publisher.html template, my template looks like; {% extends "admin/base_site.html" %} {% block title %}List of books by publisher{% endblock %} {% block content %} <div id="content-main"> <h1>List of publisher:</h1> {%regroup publisher by...

What is the regular expression for /urlchecker/http://www.google.com

I'm writing a url rewrite in django that when a person goes to http://mysite.com/urlchecker/http://www.google.com it sends the url: http://ww.google.com to a view as a string variable. I tried doing: (r'^urlchecker/(?P<url>\w+)/$', 'mysite.main.views.urlchecker'), But that didn't work. Anyone know what I'm doing wrong? Also, gene...

How do I perform HTML decoding/encoding using Python/Django?

I have a string that is html encoded: &lt;img class=&quot;size-medium wp-image-113&quot; style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot; src=&quot;http://blah.org/wp-content/uploads/2008/10/su1-300x194.jpg&amp;quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;194&quot; /&gt; I want to change that to: <img...

information seemingly coming out of mysqldb incorrectly, python django

In a latin-1 database i have '\222\222\223\225', when I try to pull this field from the django models I get back u'\u2019\u2019\u201c\u2022'. from django.db import connection (Pdb) cursor = connection.cursor() (Pdb) cursor.execute("SELECT Password from campaignusers WHERE UserID=26") (Pdb) row = cursor.fetchone() So I step into that an...

How to show the visitor a moved web page AND return a 301 redirect HTTP response status code in Django?

When a webpage has moved to a new location, how do I show the moved web page AND return a 301 permanent redirect HTTP response status code in Django? ...

Syntax error whenever I put Python code inside a Django template

I'm trying to do the following in my Django template: {% for embed in embeds %} {% embed2 = embed.replace("&lt;", "<") %} {{embed2}}<br /> {% endfor %} However, I always get an invalid block or some syntax error when I do anything like that (by that I mean {% %} code inside a loop). Python doesn't have {} to si...

Can you achieve a case insensitive 'unique' constraint in Sqlite3 (with Django)?

So let's say I'm using Python 2.5's built-in default sqlite3 and I have a Django model class with the following code: class SomeEntity(models.Model): some_field = models.CharField(max_length=50, db_index=True, unique=True) I've got the admin interface setup and everything appears to be working fine except that I can create two Som...

How can one get the set of all classes with reverse relationships for a model in Django?

Given: from django.db import models class Food(models.Model): """Food, by name.""" name = models.CharField(max_length=25) class Cat(models.Model): """A cat eats one type of food""" food = models.ForeignKey(Food) class Cow(models.Model): """A cow eats one type of food""" food = models.ForeignKey(Food) cl...

Atomic operations in Django?

I'm trying to implement (what I think is) a pretty simple data model for a counter: class VisitorDayTypeCounter(models.Model): visitType = models.CharField(max_length=60) visitDate = models.DateField('Visit Date') counter = models.IntegerField() When someone comes through, it will look for a row that matches the visitType ...

Django debugging with Emacs

I found a lot of info about how to debug simple Python programs with Emacs. But what if I want to debug a Django application? I run the development server and I would like to somehow attach to the process from Emacs and then set breakpoints, etc. Similar to Visual Studio's "attach to process". How to do that? ...

how to combine a template from other processed templates?

Hi! I have a django project pro1 with several apps: app1, app2, app3 and so on. I want to display some top level template that contains blocks from each and every app: example_base_template.html: [header /] [left nav bar]{{ app1 rendered template }}[/left nav bar] [right nav bar]{{ app2 rendered template }}[/right nav bar] [center secti...

Big integer field in django models

In short: How do you specify a BIGINT in Django models? In a current project I am doing using Django (0.97-svn release), I've all the integer fields in all the models defined as IntegerField. It was working immaculately during the development cycle where I was using SQLite for the DB backend. However, as soon as I rolled off to MySQL, ...

Django multiselect checkboxes

I have a list of objects, each with it's own checkbox, where the user can select multiple of these. The list is a result of a query. How can I mark in the view which checkboxes are already selected? There doesn't seem to be an in operator in the template language. I want something along the lines of: <input {% if id in selectedIds %}c...

Django Template System: How do I solve this looping / grouping / counting problem?

I have a list of articles, and each article belongs to a section. class Section(models.Model): name = models.CharField(max_length=200) def __unicode__(self): return self.name class Article(models.Model): section = models.ForeignKey(Section) headline = models.CharField(max_length=200) # ... I want to display the article...