I have a situation where I need to notify some users when something in DB changes. My idea is to catch pre_save and post_save signal and make some kind of diff and mail that. Generally it works good, but I don't know how to get diff for m2m fields.
At the moment I have something like this:
def pre_save(sender, **kwargs):
pk = kwar...
From django's documentation, I became under the impression that calling:
request.session.set_expiry(300)
from one view would cause the session to expire after five minutes inactivity; however, this is not the behavior that I'm experiencing in django trunk. If I call this method from one view, and browse around to other views that don'...
Hi (please, excuse me for my ugly english) !
Imagine these very simple models :
class Photo(models.Model):
is_public = models.BooleanField('Public', default=False)
class Gallery(models.Model):
photos = models.ManyToManyField('Photos', related_name='galleries', null=True, blank=True)
I need to select all Gallery instances whi...
I'm using Django along with appengine. When I try to save a record, I'm getting the error
"app_id must not be empty". The application name has been set in app.yaml. I also added
os.environ['APPLICATION_ID'] = 'test' in main.py. However, I continue to get the same error.
...
Hello I need to extend the admin view for a model so I can retrieve the items I want and use them at the extended admin templete for that model.
I couldn't find enough docs about this.
d
Thanks
...
I upgraded a working Django app to 1.1 and I now get a KeyError exception on a for loop!
Template error
In template /vol/.../templates/base_bbn.html, error at line 7
Caught an exception while rendering: 'django.contrib.comments.urls.'
You would think that there couldn't be a KeyError on a for loop like this because there would be a ...
I've been using django for a couple months now and I'm starting to get comfortable with it. At this point in my development I want to begin integrating unit testing and I've discovered unit testing a view to be tricky because of the way that django implements views with functions. For example, each function is a view/page in django if t...
If I look in Django's forms.py, as_p() calls _html_output(), which styles field errors with self.error_class() (although I can't locate the definition of that).
However, _html_output() does NOT style non_field_errors (a.k.a. top_errors in the code).
How does one style the non-field errors? Cut and paste all of _html_output?
I am usin...
I'm trying to add images to my models in my Django app.
models.py
class ImageMain(models.Model):
"""This is the Main Image of the product"""
product = models.ForeignKey(Product)
photo = models.ImageField(upload_to='products')
In development mode, every time I try to upload the image via Django admin, I keep getting:
Upload a...
I'm trying to wrap my head around the proper design to calculate an average for multiple items, in my case beers. Users of the website can review various beers and all beers are given a rating (avg of all reviews for that beer) based on those reviews. Each beer review has 5 criteria that it's rated on, and those criteria are weighted a...
From my question at http://stackoverflow.com/questions/1362426/get-foreign-key-value, I managed to get the desired output...only one last bit remains. I want to sort my records by the year, make, then model in that order. I thought it'd be as simple as Vehicle.objects.all().order_by('common_vehicle') but this doesn't sort anything.
...
Hi guys, I would like to know how to show an error message in the Django admin.
I have a private user section on my site where the user can create requests using "points". A request takes 1 or 2 points from the user's account (depending on the two type of request), so if the account has 0 points the user cant make any requests... in the...
Filtering QuerySets in Django work like the following:
Entry.objects.filter(year=2006)
How can I use filter to find all entries which does not have year 2006? Something similar to the following sql:
SELECT *
FROM entries
WHERE not year = 2006
...
I have a Django application, and I recently changed the name of the database it is supposed to use. However, manage.py doesn't seem to be using the new database.
I've doublechecked the settings.py file, and I've even added a "print settings.DATABASE_NAME" to the manage.py file, and it prints out the correct name, but still connects t...
My URLconf contains this pattern:
url(r'^accounts/logout/$','django.contrib.auth.views.logout', name="logout"),
And I've trying to reverse that in a template with the URL tag like this:
<a href="{% url logout next_page=request.path %}">logout</a>
But I keep getting the following error:
Reverse for 'logout' with arguments '()' and...
I am sending an AJAX request to a Django view that can potentially take a lot of time. It goes through some well-defined steps, however, so I would like to print status indicators to the user letting it know when it is finished doing a certain thing and has moved on to the next.
If I was using PHP it might look like this, using the flus...
I have a bunch of objects that have a value and a date field:
obj1 = Obj(date='2009-8-20', value=10)
obj2 = Obj(date='2009-8-21', value=15)
obj3 = Obj(date='2009-8-23', value=8)
I want this returned:
[10, 15, 0, 8]
or better yet, an aggregate of the total up to that point:
[10, 25, 25, 33]
I would be best to get this data direc...
hi,
i'm fairly new to django and just trying a couple simple experiments to get my feet wet. i'm running django 1.0, apache2 prefork and mod_wsgi.
I'm trying to build a site with the following url structure
/
/members
/admin
the root is basically a public area.
the members path should be protected using basic-authentication (probabl...
Is it possible to read a Django model's fields' options? For example, with the model:
class MyModel(models.Model):
source_url = models.URLField(max_length=500)
...
i.e. how would I programmatically read the 'max_length' option from, say, within a view or form.
My current workaround is to define a separate class attribute:
cl...
Hi (excuse me for my bad english) !
When I make this:
gallery_qs = Gallery.objects.all()\
.annotate(Count('photos'))\
.extra(select={'photo_id': 'photologue_photo.id'})
The sql query is :
SELECT (photologue_photo.id) AS `photo`, `photologue_gallery`.*
FROM `photologue_gallery`
LEFT OUTER ...