Hi!
I come across several problems while trying django unittests library. Something strange happens:
I defined the test like this:
from django.core import management
from django.test import TestCase
from django.test.client import Client
from django.core import mail
from django.test.utils import setup_test_environment
from django.contr...
What is the recommended idiom for checking whether a query returned any results?
Example:
orgs = Organisation.objects.filter(name__iexact = 'Fjuk inc')
# If any results
# Do this with the results without querying again.
# Else, do something else...
I suppose there are several different ways of checking this, but I'd like to know h...
Many of my views fetch external resources. I want to make sure that under heavy load I don't blow up the remote sites (and/or get banned).
I only have 1 crawler so having a central lock will work fine.
So the details: I want to allow at most 3 queries to a host per second, and have the rest block for a maximum of 15 seconds. How could ...
I have got
Foo <=> FooGroup <=> Bar
relation, where <=> stands for ManyToMany field.
How do I retrieve all the Foos for a specific Bar instance?
...
Hello, I am trying to control admin item entry where non-super user accounts can't save a ChannelStatus model input that has a date attribute which is older than 2 days. I need to get the user so that I can check if the request is a reqular or a super user but couldn't achieve this.
I have already tried "request.user.is_superuser", "use...
is there a way to get the same results of using pre-populated fields in django's admin site for slug fields in a standard modelform
...
#model
class Promotion(models.Model):
name = models.CharField(max_length=200)
start_date = models.DateTimeField()
end_date = models.DateTimeField()
#view
def promo_search(request):
...
results = Promotion.objects.filter(start_date__gte=start_date).filter(end_date__lte=end_date)
...
(The code above obviously is...
In my models.py, I user these code to extent two fields:
User.add_to_class('bio', models.TextField(blank=True))
User.add_to_class('about', models.TextField(blank=True))
But when I creat a User :
user = User.objects.create_user(username=self.cleaned_data['username'], \
email=self.cleaned_data['email'],password=self.cleaned...
I'd like to be able to run ./manage.py shell in an Emacs buffer, with all the nice stuff that you get from ipython, like magic commands and autocompletion. Ideally I would also like to be able evaluate code from a buffer to the django shell.
Is this possible?
...
Our Django application needs to do a few things with uploaded PDF files:
Verify that the file is a PDF and isn't corrupted
Check that the file isn't encrypted
Count the number of pages
We run into problems with one unfortunately popular application that's idea of an unencrypted PDF export is actually an encrypted PDF file, just with ...
I'm running django on Dreamhost right now with fastcgi, and I'm getting really weird behavior. First, the server runs Python 2.3. On my computer, I'm running 2.6 and all my source code works. When I put it on my host though, nothing works. Right now, when I pkill python and then load a page, the first error complains about a syntax err...
Hi,
I have an unusual problem. Let's consider such models (taken from django docs):
class Person(models.Model):
name = models.CharField(max_length=128)
def __unicode__(self):
return self.name
class Group(models.Model):
name = models.CharField(max_length=128)
members = models.ManyToManyField(Person, through='Me...
Hello everyone and thanks for reading.
I have a simple problem that I want to get rid of and I have not seen
examples where this is achieved yet although searching around the net
for quite a while.
I recently extended with UserProfile so my admin.py looks like this:
from django.contrib import admin
from django.contrib.auth.models impo...
Hello, I am with some trouble in Django...
After login I am losing auth session for some pages.
If I access "accounts/login/","accounts/logout/",""accounts/register/" the session always will be there, but if I access different page I cant access the user variable.
This is strange because I am using the same "base.html" for all pages ...
Hi,
I didn't want to install python modules using easy install, symlinks in site-packages or PYTHONPATH.
So, I am trying something that I do wants system wide, then any application installation is done locally. Note, the root password is required only once here.
First create a symblink of.../pythonX.Y/site-packages/mymodules -> /home/...
Lets say I have around 1,000,000 users. I want to find out what position any given user is in, and which users are around him. A user can get a new achievement at any time, and if he could see his standing update, that would be wonderful.
Honestly, every way I think of doing this would be horrendously expensive in time and/or memory. Id...
Hi!
I have following models relation:
class Section(models.Model):
section = models.CharField(max_length=200, unique=True)
name = models.CharField(max_length=200, blank = True)
class Article (models.Model):
url = models.CharField(max_length = 30, unique=True)
is_published = models.BooleanField()
section = models...
Hi all,
I am trying to create a drop down list box with the selected value equal to a value passed from the template values, but with no success. Can anyone take a look and show me what I am doing wrong.
<select name="movie">
{% for movie in movies %}
{% ifequal movie.id selected_movie.id %}
<option value="{{movie.k...
How do I make a Django form where the user can choose between several ways of providing the data, and I need one of them to be valid.
Say that I have a user profile where the user can choose between profile picture as URL or a imagefile:
class UserProfile(forms.Form):
picture_url = forms.URLField()
picture_file = forms.ImageFie...
We are working on a .po file editor for translators. And the translators need to see the changes they are doing on the live website.
We managed to reload the .mo files for the current process/thread. but not for every process/thread.
Is there a possibility to accomplish this without bigger performance problems?
...