Is there some way (using the standard Django.test.TestCase framework) to perform a global initialization of certain variables, so that it only happens once.
Putting things setUp() makes it so that the variables are initialized before each test, which kills performance when the setup involves expensive operations. I'd like to run a setup...
Hi everybody!
What I'm trying to do is to manage several forms in one page, I know there are formsets, and I know how the form management works, but I got some problems with the idea I have in mind.
Just to help you to imagine what my problem is I'm going to use the django example models:
from django.db import models
class Poll(model...
I've created a custom view to make some data entry easier and I want to add a link to it on the front page of the Django admin. Is there an easy way to do this?
I suppose I could override the default admin template, but before I do that I just want to make sure there isn't something simpler I could do.
...
I set a session like this:
request.session['mykey']= 33
How do I clear it? I just want to DELETE it.
...
What i'm trying to achieve at this point:
Allow me to add new shoe objects, and shoe review objects. complete
Allow "Owner Reviews" on each shoe complete (I think, but there might be somewhere in my model I can improve)
Allow ratings of attributes defined by me which are linked to a particular shoe. Preferably, having an easy way to it...
I have altered the default manager on some of the objects which a GenericForeignKey() can reference such that those objects may no longer appear within that default manager.
I have other managers which will be able to find these deleted objects, but I see no way to tell the content types framework about them. Is this possible?
I am imp...
I'm developing a website using the Django framework, and I need to retrieve Jabber (okay, Google Talk) statuses for a user. Most of the Jabber python libraries seem like an incredible amount of overkill (and overhead) for a simple task. Is there any simple way to do this?
I know very little about XMPP/Jabber, though of course I'm willi...
I'm running a Django site (via Apache/mod_python) and I use Django's facilities to inform me and other developers about internal server errors. Sometimes errors like those appear:
Traceback (most recent call last):
File "/opt/webapp/externals/lib/django/core/handlers/base.py", line 92, in get_response
response = callback(request,...
Hello there,
I came across this blog entry which describes an elegant way of handling results returned from a ChoiceField to a view using a list comprehension technique - one that eliminates empty keys/values without all the intermediate data structures. This particular approach doesn't seem to work for MultipeChoiceFields, though. Is t...
I have 3 models with various fields in each. For 2 of the models, I'm fine with using a generic form (through Django's create_object) to request data. I wrote a function that accepts the model name and sends the user to the generic form
url(r'^add_(?P<modelname>\w+)/$', generic_add),
def generic_add(request, modelname):
mdlnm_mod...
Is there an easy way to limit the number of times a view can be accessed by a given IP address per day/week? A simplified version of the technique used by some booksellers to limit the number of pages of a book you can preview?
There's only one view that this limit need apply to--i.e. it's not a general limit--and it would be nice if I ...
I've searched SO and the Django doc and can't seem to be able to find this. I'm extending the base functionality of the django.contrib.comments app to use the custom permission system that's in my webapp. For the moderation actions, I'm attempting to use a class-based view to handle the basic querying of the comment and permission chec...
Consider the following Django Model:
class Event(models.Model):
startDate = models.DateField()
endDate = models.DateField()
user = models.ForeignKey(User, null=True)
Later in my view I do this:
django.core.serializers.serialize("json", Event.objects.all())
return HttpResponse(data, mimetype='application/javascript')
...
Hi,
Is it possible to instantiate a subclassed model from its parent?
class Object1(models.Model):
field1a = models.CharField()
field1b = models.CharField()
feild1c = models.ForeignKey(Object4)
class Object2(Object1):
field3 = models.CharField()
class Object3(Object1):
field3 = models.CharField()
class Object4(models...
Hi all, I have this code:
msgs = int(post['time_in_weeks'])
for i in range(msgs):
tip_msg = Tip.objects.get(week_number=i)
it always results in an error saying that no values could be found.
week_number is an integer field. When I input the value of i directly,
the query works.
When i print out the value of i I get the expected ...
Is it possible to access the forloop.counter for the outermost for loop in the following template in Django:
{% for outerItem in outerItems %}
{% for item in items%}
<div>{{ forloop.counter }}. {{ item }}</div>
{% endfor %}
{% endfor %}
forloop.counter returns the innermost for loop's counter in the above example
...
I'm putting together a very basic time-lapse sequence of images (about 120 images total).
I've installed imagekit, adjusted the specs.py file to my needs, populated the database with "pointers", imagekit has generated thumbnails.....all is well.
my views.py includes:
def pics(request):
p = Photo.objects.all()
return...
I'm trying to set up a Django project in Eclipse, and I'm getting stuck while trying to set up the development server for Run & Debug configurations. I've been following the following example: http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html.
I've created a new run configuration in Eclipse, set the project a...
I'm new to Django but I seem to have nearly identical code working on another site. I can update a record in the Django shell, but in view.py the same code insists on INSERTing a new record when I run this form.
I have a "DisciplineEvent" object in the model. I let Django create the "id" field for the primary key. I can see the "id" i...
If I'm building an application that will have over 30 models, and I want the option to plug in a custom manager or other functionality into all the models down the road, is it a good idea to use an abstract base model and subclass it with every model, or is there compelling reasons not to do this?
...