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...
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 ...
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?
...
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...
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...
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...
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:
...
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...
How i can get the current settings in a custom command and not the defaul settings?
...
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...
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'...
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 ...
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'...
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...
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'...
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...
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
...
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
#...
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...
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(...