django

RabbitMQ / Celery with Django hangs on delay/ready/etc - No useful log info

Hi, So I just setup celery and rabbitmq, created my user, setup the vhost, mapped the user to the vhost, and ran the celery daemon succesfully (or so I assume) (queuetest)corky@corky-server:~/projects/queuetest$ ./manage.py celeryd celery@corky-server v0.9.5 is starting. Configuration -> . broker -> amqp://celery@localhost:5672/ . qu...

Are Django's QuerySets lazy enough to cope with large data sets?

I think I've read somewhere that Django's ORM lazily loads objects. Let's say I want to update a large set of objects (say 500,000) in a batch-update operation. Would it be possible to simply iterate over a very large QuerySet, loading, updating and saving objects as I go? Similarly if I wanted to allow a paginated view of all of these ...

Fastest Way to Update a bunch of records in queryset in Django

I have a queryset with a few million records. I need to update a Boolean Value, fundamentally toggle it, so that in the database table the values are reset. What's the fastest way to do that? I tried traversing the queryset and updating and saving each record, that obviously takes ages? We need to do this very fast, any suggestions? ...

Ranking within Django ORM or SQL?

Hi, so... I have a huge list ranked by various values (eg. scores) So I grab the list ordered by these values: players = Player.objects.order_by('-score', '-karma') I would like to: Grab a player and get the neighbouring players P1 score:123 P2 score:122 YOU! score:110 P3 score:90 P2 score:89 Grab the...

Django: Best way to implement "status" field in modules

I have a field in my module that is used to hold the status of the object. So far I have used: ORDER_STATUS = ((0, 'Started'), (1, 'Done'), (2, 'Error')) status = models.SmallIntegerField(choices=ORDER_STATUS) Its easy to convert one way: def status_str(self): return ORDER_STATUS[self.status][1] The problem is when updating. I find...

Django: Does model_instance.clean() run before basic validators?

Let's say that I have a model: class Ticket(models.Model): client = models.ForeignKey(Client) color = models.CharField(max_length=255) def clean(self): self.color = self.client.favorite_color When I run this on the latest Django (head of the SVN from 15 minutes ago), if I hit save without selecting a client, I get...

MultiValueKeyDict error in Django authentication documentation

I'm trying to follow the code from http://docs.djangoproject.com/en/1.1/topics/auth/ regarding user logins. def my_view(request): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: ...

What does this error mean: The model User has two manually-defined m2m relations ...

I'm running into this error when I attempt to syncdb: auth.user: The model User has two manually-defined m2m relations through the model FavoriteQuestion, which is not permitted. Please consider using an extra field on your intermediary model instead. I'm really don't understand what it means because I only see 1 model-to-model relation...

django custom command

How i can get the current settings in a custom command and not the defaul settings? ...

How do I get the "Interests" of a facebook user uing Facebook Connect? (I'm using Django/python and pyFacebook middleware)

def index(request): fbdata = [] if request.facebook.check_session(request): fbdata = request.facebook.users.getInfo(request.facebook.uid, ['name', 'pic']) print fbdata This works! I am able to get the user's picture and name. However...I'd like to get the interests of that user. How can I do that? By the way, I i...

Returning a value with psycopg2

Ideally I'd like to be able to do something like: id_of_new_row = cursor.lastrowid() in which I get the id of the newly created or modified row. But this isn't available through psycopg2. Alternatively, I've tried this: id_of_new_row = cursor.execute('INSERT INTO this_table (value1, value2, value3) VALUES (%s, %s, %s) RETURNING id'...

Is it possible to reference a property using Django's QuerySet.values_list?

I have a custom property on my Django model that returns the full name of a Person: class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) def _get_full_name(self): return "%s %s" % (self.first_name, self.last_name) full_name = property(_get_full_name) When I create ...

Django: Where does "DoesNotExist" come from?

All the time in Django I see DoesNotExist being raised like in db.models.fields.related.py. Not ObjectDoesNotExist which is defined in django.core.exceptions, but just DoesNotExist. Where is this exception class defined, or am I not fully understanding exceptions? I've checked that it's not in exceptions (at least not that I know of). I'...

How do I use Trac wiki formatting in a Django/Python web application?

I have a Python web application (Django, specifically). I'm reading in some data from a Trac database (where the descriptions use wiki formatting) and displaying it as HTML. I considered the markdown module, but realised that Trac wiki formatting and markdown are really quite different. Is there a module for Django, or a Python package t...

deployment systems with web-interface other than capistrano?

Hi. I'm running production server with 12 projects written in PHP and Python (Django framework). The problem is that every time i commit something to svn i have to ssh to server and do svn update manually. I've made a simple shell script for this, but it's definitenly not an option. I thought about capistrano+webistrano, but for this i'...

How to set up Django development environment without installing?

Hi, I'm a student and the lab staff has set up permissions that won't students install software on the machines (or to our profiles). I'm curious how I can develop Django application in a contained environment. I checked out the Django trunk to my Ubuntu home directory and added the bin path to my .bashrc. But when I try to use django-a...

what is {% trans "This is the title." %} used for,i can't understand the api.

i know the {% trans %} is for translation, and how can i translate {% trans "This is the title." %} to chinese. thanks D:\zjm_code\register2>python D:\Python25\Lib\site-packages\django\bin\django-adm in.py compilemessages processing file django.po in D:\zjm_code\register2\locale\cn\LC_MESSAGES msgfmt: iconv failure ...

my pythonpath has 'register2',why i can't import it

import sys print sys.path ['D:\\zjm_code\\register2', 'C:\\WINDOWS\\system32\\python25.zip', 'D:\\Python25\\DLLs', 'D:\\Python25\\lib', 'D:\\Python25\\lib\\plat-win', 'D:\\Python25\\lib\\lib-tk', 'D:\\Python25', 'D:\\Python25\\lib\\site-packages'] and #from django.core.management import setup_environ from register2 import settings #...

Why can't I use 'django-admin.py makemessages -l cn'

print : D:\zjm_code\register2>python D:\Python25\Lib\site-packages\django\bin\django-adm in.py makemessages -l cn Error: This script should be run from the Django SVN tree or your project or app tree. If you did indeed run it from the SVN checkout or your project or applica tion, maybe you are just missing the conf/locale (in the djang...

Getting Django Query Count While in manage.py shell

Is there a way to count my queries during a manage.py shell session? It would be helpful as a means to inspect some of the ORM behavior between queries. Additionally, it would be nice to pull the queries themselves, and I guess their execution times while I'm at it. i.e. >>>from myapp.models import User >>>User.objects.filter(...