Re: Repetitive background tasks
Thanks everyone for the replies. Anyways I looked at the kronos scheduler (pointed out by Canen above) being used in Turbogears and what I wanted is more like this. So currently the way I'm using this is to put kronos.py into the django utils directory and then importing it from there. In a particular view, I start a threaded scheduler if it hasn't been started yet and I assign the repetitive task to it. This way the view's response is instantaneous even the first time because the task will be running in a separate thread. This seems to work for me! Anyways I think it will be useful if Django has a scheduler like this one included by default like TurboGears (actually it does not seem to require much effort; just have to reuse the code in kronos.py). Cheers, Harish --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Malcolm Tredinnick wrote: > On Tue, 2006-06-27 at 23:09 -0500, Patrick .J. Anderson wrote: >> Jacob Kaplan-Moss wrote: >>> Hi Patrick -- >>> >>> What happens when you clear out your sessions table? >>> >>> FYI, there's nothing about Ubuntu versus mod_python that would/could >>> cause this (I use both). >>> >>> Jacob >>> >> I cleared the session table and tried to login using my >> apache/mod_python virtual host setup. This is the session_key I get: >> >> 0abcebfdaff71c28a368d8bd >> >> >> When I log in using the development server, I can login successfully and >> the session_key I see is: >> >> 6b668c51d7d4fddd89c14e14e0569417 >> >> >> These are obviously very different, particularly the 0s in the beginning >> of the session_key from mod_python. > > One common thing that I noticed between your current problem (which > looks a lot like Nikolaus Shlemm's md5 sum problem) and the original > problem Nikolaus demonstrated on the mod_python list is that you are > both using a reasonably recent Ubuntu installation. No idea why that > will contribute (or even if it is a differentiating factor), but it's > something to note. > > Malcolm > > > > > Hi, Malcolm Yes, I noticed that too. Perhaps it would be good if I tested this behaviour on another distro, but I don't want to resetup my development machine again. Maybe someone with a distro other than Ubuntu Dapper could compare the session_keys in django_sessions table with mod_python as well as builtin server, and see if this is also happening. Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Problem with built-in User in many-to-many relationships
Malcolm Tredinnick wrote: On Tue, 2006-06-27 at 23:53 -0400, bsdlogical wrote: I've recently stumbled over a problem whose solution I can't find. I have a class with two fields that use the built-in User class (from django.contrib.auth.models) in a many-to-many relationship. However, when I try to access or modify those fields, django throws an error message. My class declaration is: class Organization(models.Model): name = models.CharField(maxlength=40) sponsor = models.ManyToManyField(User, related_name='sponsored_orgs', null=True) members = models.ManyToManyField(User, related_name='orgs_belonged_to', null=True) test = models.ForeignKey(User) The following code: o = Organization() o.sponsor causes an error after the second line: Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.4/site-packages/django/db/models/fields/related.py", line 405, in __get__ target_col_name=qn(self.field.m2m_reverse_name()) File "/usr/local/lib/python2.4/site-packages/django/db/models/fields/related.py", line 244, in __init__ raise ValueError("%r instance needs to have a primary key value before a many-to-many relationship can be used." % model) ValueError: instance needs to have a primary key value before a many-to-many relationship can be used. When you create a many-to-many association, we store the pair of related primary key values in the "join" table in the database. In order to store that pair, both objects need to *have* a primary key. A new object does not receive a primary key value until you save it (unless you manually set the value yourself). This will work: o = Organization() o.save() o.sponser Regards, Malcolm That definitely solved the problem. Thanks for the explanation! Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
On Tue, 2006-06-27 at 23:09 -0500, Patrick .J. Anderson wrote: > Jacob Kaplan-Moss wrote: > > Hi Patrick -- > > > > What happens when you clear out your sessions table? > > > > FYI, there's nothing about Ubuntu versus mod_python that would/could > > cause this (I use both). > > > > Jacob > > > > > > > > I cleared the session table and tried to login using my > apache/mod_python virtual host setup. This is the session_key I get: > > 0abcebfdaff71c28a368d8bd > > > When I log in using the development server, I can login successfully and > the session_key I see is: > > 6b668c51d7d4fddd89c14e14e0569417 > > > These are obviously very different, particularly the 0s in the beginning > of the session_key from mod_python. One common thing that I noticed between your current problem (which looks a lot like Nikolaus Shlemm's md5 sum problem) and the original problem Nikolaus demonstrated on the mod_python list is that you are both using a reasonably recent Ubuntu installation. No idea why that will contribute (or even if it is a differentiating factor), but it's something to note. Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Jacob Kaplan-Moss wrote: > Hi Patrick -- > > What happens when you clear out your sessions table? > > FYI, there's nothing about Ubuntu versus mod_python that would/could > cause this (I use both). > > Jacob > > > > I cleared the session table and tried to login using my apache/mod_python virtual host setup. This is the session_key I get: 0abcebfdaff71c28a368d8bd When I log in using the development server, I can login successfully and the session_key I see is: 6b668c51d7d4fddd89c14e14e0569417 These are obviously very different, particularly the 0s in the beginning of the session_key from mod_python. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Problem with built-in User in many-to-many relationships
On Tue, 2006-06-27 at 23:53 -0400, bsdlogical wrote: > I've recently stumbled over a problem whose solution I can't find. I > have a class with two fields that use the built-in User class (from > django.contrib.auth.models) in a many-to-many relationship. However, > when I try to access or modify those fields, django throws an error > message. My class declaration is: > > class Organization(models.Model): > name = models.CharField(maxlength=40) > sponsor = models.ManyToManyField(User, > related_name='sponsored_orgs', null=True) > members = models.ManyToManyField(User, > related_name='orgs_belonged_to', null=True) > test = models.ForeignKey(User) > > The following code: > o = Organization() > o.sponsor > > causes an error after the second line: > Traceback (most recent call last): > File "", line 1, in ? > File > "/usr/local/lib/python2.4/site-packages/django/db/models/fields/related.py", > line 405, in __get__ > target_col_name=qn(self.field.m2m_reverse_name()) > File > "/usr/local/lib/python2.4/site-packages/django/db/models/fields/related.py", > line 244, in __init__ > raise ValueError("%r instance needs to have a primary key value > before a many-to-many relationship can be used." % model) > ValueError: instance needs to > have a primary key value before a many-to-many relationship can be used. When you create a many-to-many association, we store the pair of related primary key values in the "join" table in the database. In order to store that pair, both objects need to *have* a primary key. A new object does not receive a primary key value until you save it (unless you manually set the value yourself). This will work: o = Organization() o.save() o.sponser Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Nikolaus Schlemm wrote: >> I've heard that the problem might be related to md5 hashing (someone >> just recently posted it here in the groups with the same error >> message). I looked at the django code and that where that error message >> is thrown and it seemed to confirm that, but I don't know why this >> happens. > simply try generating the reference hashes provided at the end of the md5 > rfc[1] within a django-view - if they are not calculated correctly, you might > want to switch from md5 to sha for a quick workaround and possibly follow the > thread on the modpy mailinglist[2]. > > another solution might be something along the lines of the patch I posted > earlier[3] - but of course, I don't know whether or when this will make it in > into django ;) > > [1] http://www.ietf.org/rfc/rfc1321.txt > [2] http://modpython.org/pipermail/mod_python/2006-June/021482.html > [3] > http://groups.google.com/group/django-users/browse_thread/thread/eeb44c894342d6f7/4b951b6d3a8644dd Hmm, I don't want to modify the framework code and start creating this sort of workarounds since I use django-trunk... I guess I'll have to wait until this problem is resolved, though I thought Django was for developers with deadlines :) Well, this makes me a little cautious in using the framework for my web development. Sad, 'cause I liked it. But I'll dig for more info and try to find a solution --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Problem with built-in User in many-to-many relationships
I've recently stumbled over a problem whose solution I can't find. I have a class with two fields that use the built-in User class (from django.contrib.auth.models) in a many-to-many relationship. However, when I try to access or modify those fields, django throws an error message. My class declaration is: class Organization(models.Model): name = models.CharField(maxlength=40) sponsor = models.ManyToManyField(User, related_name='sponsored_orgs', null=True) members = models.ManyToManyField(User, related_name='orgs_belonged_to', null=True) test = models.ForeignKey(User) The following code: o = Organization() o.sponsor causes an error after the second line: Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.4/site-packages/django/db/models/fields/related.py", line 405, in __get__ target_col_name=qn(self.field.m2m_reverse_name()) File "/usr/local/lib/python2.4/site-packages/django/db/models/fields/related.py", line 244, in __init__ raise ValueError("%r instance needs to have a primary key value before a many-to-many relationship can be used." % model) ValueError: instance needs to have a primary key value before a many-to-many relationship can be used. I'm not sure what causes this. The test ForeignKey causes no problems. Even if I do o.sponsor.any.random.text(), the same error occurs. Has anyone else seen this issue? I would greatly appreciate any help. Thanks, Nick Fishman --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Hi Patrick -- What happens when you clear out your sessions table? FYI, there's nothing about Ubuntu versus mod_python that would/could cause this (I use both). Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Patrick .J. Anderson wrote: > [EMAIL PROTECTED] wrote: >> Clear the cookies in your browser and the problem will go away. >> >> > clearing the cookies doesn't help (I guess you answered that one). > > hmm, i don't know exactly what to do here, as I haven't tampered with > anything. I'll try to recreate the project (extra work, but maybe it'll > work) > > > > > I recreated the project using django-admin.py (of course, I restored my models and database), but still experience this behaviour and error messsages when I try to log in to admin section. Weird, as everything I have in my settings.py file is new and I obviously haven't tampered with the session. If this is a problem with mod_python in Ubuntu, I'll have to switch back to FC5 where things 'worked'. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Generic relations and tags
Jay Parlar wrote: > That's a pretty neat way to do it, I'm going to have to try it out. Do > you use a ManyToManyField between your actual objects (like a blog > Post, for instance) and the ObjectTag? > > Jay P. hi Jay, Since the ObjectTag model is the m2m table between the actual object (which will be tagged) and the Tag model, so, you just add the GenericRalation to you target object would be ok: class Post(models.Model): tags = models.GenericRelation(ObjectTag) AFAIK, using the GenericForeignKey & GenericRelation does NOT create any actual db tables or added any extra table fields, they've just added a convenient way for easily access this kind of generic relation. (let me know if I was wrong :) you could simply remove the GenericForeignKey from the ObjectTag model and remove the GenericRelation from the Post, then, via the content_type & object_id fields of the ObjectTag, you can query for the tags of a specific Post object by querying the ObjectTag & Tag table together. - Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django t-shirts: your ideas wanted!
On Jun 27, 2006, at 10:04 PM, Julio Nobrega wrote: > Django | Python: We indented jazz (some people say jazz' magic is > the space between the notes, a definition that I love) Ha -- that one makes me laugh... :) Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django t-shirts: your ideas wanted!
You asked :) The green one from the flickr photo with this one liner in the back: ['hotclub' for name in frameworks if name is 'django'] Or this on the back: MVU (Just a play with the words. Controller is You, heh, heh? :p Okay...) Django: From Web 2.0 to Web Quintette Snakes on an OSCON Django: All the jazz and less typing too! (Okay, bad taste...) Django | Python: We indented jazz (some people say jazz' magic is the space between the notes, a definition that I love) On 6/27/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > Howdy folks -- > > I'm about to print up some Django shirts to take to OSCON next month > -- got any ideas? > > We gotta move pretty fast (we're going to try to get an order in to > the printer this week) so if you've got any hot ideas (or designs, > for that matter) send 'em to me! > > I'll mail anyone who gives an idea or a design one of the final > shirts, but otherwise please don't ask about "ordering" or otherwise > "getting" one. If there are any left after OSCON I'll make an > announcement then, but this are intended for OSCON promotions. > > For your reference, here's the one we did for PyCon: http:// > flickr.com/photos/uhop/104501907/. We'll reprint that one if we > don't get any better ideas. > > Let 'em rip! > > Jacob > > > > > -- Julio Nobrega - http://www.inerciasensorial.com.br --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django t-shirts: your ideas wanted!
I second these. It'd be nice if they came in Django-green, as well. -Tyson -- Tyson Tate - CalPoly Graphic Design Student - Work: Graphic Designer (CalPoly Library) - Play: Mustang Band, CalPoly Triathlon Team, Kappa Kappa Psi (Iota Pi) On Jun 27, 2006, at 11:57 AM, Don Arbow wrote: > These seemed nice, not sure if they're the same as those below, > these were at the Greenpeace Rails show and tell: > > http://www.flickr.com/photos/[EMAIL PROTECTED]/173107581/in/ > set-72157594174657013/ > http://www.flickr.com/photos/[EMAIL PROTECTED]/173107223/in/ > set-72157594174657013/ > > Don --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
[EMAIL PROTECTED] wrote: > Clear the cookies in your browser and the problem will go away. > > > > > clearing the cookies doesn't help (I guess you answered that one). hmm, i don't know exactly what to do here, as I haven't tampered with anything. I'll try to recreate the project (extra work, but maybe it'll work) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Maintaining foreign key reference when foreign object gets deleted
On 6/27/06, mohan <[EMAIL PROTECTED]> wrote: > But then we would loose the relation between objects. A database can only maintain relationships between two objects if both objects actually exist in their respective tables. Deleting one or the other will always irretrievably destroy the relationship. The boolean "is_deleted" flag on the Centre class may be your best bet, since it lets you filter "deleted" Centres out of most results while still maintaining the relationship with other objects. -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: syncdb error: django.contrib.markup: 'module' object has no attribute 'models'
On 6/27/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > > The error message is the result of a recent addition (r3201) - it is an > indication that the named applications could not be imported, because of > some sort of error in the code - in this case, the request for a 'models' > attribute that doesn't exist. This is an offshoot of bug #1812. > > Previously, this error would not have been detected - the import process > would have silently failed, and moved on. > > The only reason that your powerbook wouldn't be seeing this error is if; > 1) You are not running r3201 or greater on your powerbook > 2) settings.py on your powerbook is not including those two applications. > The answer is 1. Oops. I'm currently running Django on four different computers, guess I just forgot to update. Glad to know where it's coming from though. Thanks, Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Maintaining foreign key reference when foreign object gets deleted
But then we would loose the relation between objects. We still want to maintain the information as to what was delivered to whom even though the centre gets deleted. Yes, we could maintain a couple of extra columns/tables to maintain the status. But this would mean looking for in mulitple places when we need information. Is n't there a more natural way of doing this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Request_Response Problem
Simon,Malcolm, thank you for your quick replies.:)I need to read the docs more carefull.On 6/28/06, Malcolm Tredinnick < [EMAIL PROTECTED]> wrote:On Wed, 2006-06-28 at 09:21 +0800, HoLin wrote: > hi all> I have a Query_String like this :> ?type_encode=0=python=.cn=.com=.net>> using request.REQUEST.get("root") can only get the last value *.net* > how can I get the right value of root?The behaviour of this dicitionary-like object is documented in [1], but,basically, request.REQUEST.get(...) retrieves the last of multiplevalues, whilst request.REQUEST.getlist (...) retrieves all of them.[1]http://www.djangoproject.com/documentation/request_response/#querydict-objects Regards,Malcolm-- RegardsHoLin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Request_Response Problem
On Wed, 2006-06-28 at 09:21 +0800, HoLin wrote: > hi all > I have a Query_String like this : > ?type_encode=0=python=.cn=.com=.net > > using request.REQUEST.get("root") can only get the last value *.net* > how can I get the right value of root? The behaviour of this dicitionary-like object is documented in [1], but, basically, request.REQUEST.get(...) retrieves the last of multiple values, whilst request.REQUEST.getlist(...) retrieves all of them. [1] http://www.djangoproject.com/documentation/request_response/#querydict-objects Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Request_Response Problem
On 28 Jun 2006, at 02:21, HoLin wrote: > ?type_encode=0=python=.cn=.com=.net > > using request.REQUEST.get("root") can only get the last value *.net* > how can I get the right value of root? request.GET.getlist('root') will get you back a list of all of the root= values. This is one of my favourite features of Django's request handling. PHP only ever gives you back the last value (unless you use root[] =blah[]=blah2 which is a bit weird). Python's cgi module ALWAYS gives you back a list, even though 99% of the time you only want one value. With Django, we decided to make the common case (a single value) act like a dictionary, but provided an explicit mechanism for accessing lists of values. You can rely on the fact that request.GET [key] will only ever return a single string, while request.GET.getlist (key) will always return a list of strings (or an empty list). Cheers, Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Request_Response Problem
hi allI have a Query_String like this :?type_encode=0=python=.cn=.com=.netusing request.REQUEST.get("root") can only get the last value *.net*how can I get the right value of root? -- RegardsHoLin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: syncdb error: django.contrib.markup: 'module' object has no attribute 'models'
On 6/28/06, Jay Parlar <[EMAIL PROTECTED]> wrote: When running my Django instance (most up to date SVN) on Dreamhost,I've started seeing this:[chiclet]$ python2.4 manage.py syncdbError: None couldn't be installed, because there were errors in your model: django.contrib.humanize: 'module' object has no attribute 'models'django.contrib.markup: 'module' object has no attribute 'models'The error message is the result of a recent addition (r3201) - it is an indication that the named applications could not be imported, because of some sort of error in the code - in this case, the request for a 'models' attribute that doesn't exist. This is an offshoot of bug #1812. Previously, this error would not have been detected - the import process would have silently failed, and moved on. The only reason that your powerbook wouldn't be seeing this error is if;1) You are not running r3201 or greater on your powerbook 2) settings.py on your powerbook is not including those two applications.Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: syncdb error: django.contrib.markup: 'module' object has no attribute 'models'
On Tue, 2006-06-27 at 20:58 -0400, Jay Parlar wrote: > When running my Django instance (most up to date SVN) on Dreamhost, > I've started seeing this: > > [chiclet]$ python2.4 manage.py syncdb > Error: None couldn't be installed, because there were errors in your model: > django.contrib.humanize: 'module' object has no attribute 'models' > django.contrib.markup: 'module' object has no attribute 'models' > > Anyone know why? I can't track it down. The exact same code (except > slightly different settings.py) on my Powerbook gives no such > complaint. This is ticket #1812: a slight regression caused by some other fixes. I'm planning to check in a fix over lunchtime today (in a couple of hours). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Generic relations and tags
On 6/27/06, Luke Plant <[EMAIL PROTECTED]> wrote: > > On Tuesday 27 June 2006 18:06, Jay Parlar wrote: > > So I'm now trying the new generic relations out for tags, much like > > the example in the documentation. The problem I'm having is doing a > > filter() to get a QuerySet of tags with unique names. Any thoughts on > > this? > > > > If two different objects are both given a tag "foo", there will be > > two tags in the system that have 'foo' as their 'tag' value. The only > > way I can think of doing this so far is to manually pull all the > > results out of a QuerySet, and use Python to figure out all the > > unique tag names. > > Would something like this do it? > > your_query_set.distinct().values('tag') Oh wow, that seems to work perfectly. Thanks, Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Null foreign key, is this possible?
On Tue, 2006-06-27 at 15:25 -0700, bahund wrote: > Hi, > > I have the following model which has a foreign key field that I would > like to be null at times: > > class Car(models.Model): > make = models.CharField(maxlength=100, core=True) > model = models.CharFeild(maxlength=100, core=True) > date = models.DateTimeField(auto_now_add=True) > forum = models.ForeignKey(Forum, blank=True, null=True) > > Even with the "blank=True" and "null=True" arguments it still will not > allow inserts. I've tried a combination of these two arguments (just > one or the other) and that didn't work either. I found the following > post and it seemed to work for them so I'm wondering if anyone can see > the problem with my situation. > > http://groups.google.com/group/django-users/browse_thread/thread/ff921044d994f336/a42316a8049e8c6d?q=null+foreign+key=10#a42316a8049e8c6d > > The admin is kicking back the following error: > > ERROR: null value in column "forum_id" violates not-null constraint > INSERT INTO "search_car" ("make","model","date","forum_id") VALUES > ('VW','Jetta','2006-06-27 23 I would guess you initially created the model without the null = True and then ran syncdb. That will create the relevant database column with a "NOT NULL" constraint (have a look at the *_car table in your database to check this. Since "null = True" affects the database (by permitting the column to be nullable), you need to fix the SQL for that model. Either use "./manage.py reset " if you can afford to lose the data already in the tables, or run "./manage.py sql ", look at what the column should be and create the appropriate "ALTER TABLE..." SQL commands that you apply by hand. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Generic relations and tags
On Tuesday 27 June 2006 18:06, Jay Parlar wrote: > So I'm now trying the new generic relations out for tags, much like > the example in the documentation. The problem I'm having is doing a > filter() to get a QuerySet of tags with unique names. Any thoughts on > this? > > If two different objects are both given a tag "foo", there will be > two tags in the system that have 'foo' as their 'tag' value. The only > way I can think of doing this so far is to manually pull all the > results out of a QuerySet, and use Python to figure out all the > unique tag names. Would something like this do it? your_query_set.distinct().values('tag') Luke -- "Defeat: For every winner, there are dozens of losers. Odds are you're one of them." (despair.com) Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Null foreign key, is this possible?
Hi, I have the following model which has a foreign key field that I would like to be null at times: class Car(models.Model): make = models.CharField(maxlength=100, core=True) model = models.CharFeild(maxlength=100, core=True) date = models.DateTimeField(auto_now_add=True) forum = models.ForeignKey(Forum, blank=True, null=True) Even with the "blank=True" and "null=True" arguments it still will not allow inserts. I've tried a combination of these two arguments (just one or the other) and that didn't work either. I found the following post and it seemed to work for them so I'm wondering if anyone can see the problem with my situation. http://groups.google.com/group/django-users/browse_thread/thread/ff921044d994f336/a42316a8049e8c6d?q=null+foreign+key=10#a42316a8049e8c6d The admin is kicking back the following error: ERROR: null value in column "forum_id" violates not-null constraint INSERT INTO "search_car" ("make","model","date","forum_id") VALUES ('VW','Jetta','2006-06-27 23 Thanks in advance! Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: admin connection mysql problem
On 6/26/06, Patrick <[EMAIL PROTECTED]> wrote: > File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 151, > in __init__ > self.converter[types.StringType] = string_literal > > TypeError: object does not support item assignment I don't really know what the actual cause is, and I've seen this reported several times, but if you are getting this, something is probably botched with your MySQLdb installation. I recommend using version 1.2.1, particularly if you are using MySQL-4.1 or newer (a must-have for MySQL-5.0 or newer). If you are manually installing MySQLdb (a.k.a. MySQL-python), be sure you remove all traces of the 1.2.0 installation before installing 1.2.1; otherwise you will have a mysterious import error involving the sets module. If you are using some sort of package management system, this is not likely to be an issue, as it should remove obsolete files automatically. This isn't actually a Django issue, so if you still have problems, follow-up in the help forum over at http://sourceforge.net/projects/mysql-python (http://sourceforge.net/forum/forum.php?forum_id=70461). (Don't file a bug; it's a problem with your installation.) -- The Pythonic Principle: Python works the way it does because if it didn't, it wouldn't be Python. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django t-shirts: your ideas wanted!
These seemed nice, not sure if they're the same as those below, these were at the Greenpeace Rails show and tell:http://www.flickr.com/photos/[EMAIL PROTECTED]/173107581/in/set-72157594174657013/http://www.flickr.com/photos/[EMAIL PROTECTED]/173107223/in/set-72157594174657013/DonOn Jun 27, 2006, at 11:34 AM, Jacob Kaplan-Moss wrote:http:// flickr.com/photos/uhop/104501907/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Problem authenticating static content in Apache
Ah... upgrading to the latest mod_python (3.2.8) seemed to fix the problem. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: How to select distinct rows?
On Jun 26, 2006, at 12:14 PM, Ville Säävuori wrote: > Say I have a model like > > class Example (models.Model): > ip = models.IPAddressField() > desc = models.CharField(maxlength=255) > created = models.DateTimeField(auto_now_add=True) > > How do I make a query that counts distinct objects by ip (or any other > field that is not pk)? It's quite simple with raw SQL, but is there > some other way of doing this (on MR)? ``Example.objects.filter(ip__exact=IP).distinct().count()`` gets you a count of objects with a given ``IP``; if you want a typical ``SELECT ip, COUNT(*)...`` type query then you'll need to do it by hand. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Django t-shirts: your ideas wanted!
Howdy folks -- I'm about to print up some Django shirts to take to OSCON next month -- got any ideas? We gotta move pretty fast (we're going to try to get an order in to the printer this week) so if you've got any hot ideas (or designs, for that matter) send 'em to me! I'll mail anyone who gives an idea or a design one of the final shirts, but otherwise please don't ask about "ordering" or otherwise "getting" one. If there are any left after OSCON I'll make an announcement then, but this are intended for OSCON promotions. For your reference, here's the one we did for PyCon: http:// flickr.com/photos/uhop/104501907/. We'll reprint that one if we don't get any better ideas. Let 'em rip! Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Generic relations and tags
On 6/27/06, nkeric <[EMAIL PROTECTED]> wrote: > > hi Jay, > > IMO, you will have to do the unique contrain in the db level, here is > the tagging model stuff I'm working on: > That's a pretty neat way to do it, I'm going to have to try it out. Do you use a ManyToManyField between your actual objects (like a blog Post, for instance) and the ObjectTag? Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Errors using django.contrib.*.view
Sorry one last shot at this ... the import line in django.contrib.syndication.views should be: from django.contrib.syndication import feeds --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: admin connection mysql problem
Patrick Martini wrote: > Thanks for the answer :) > I have tries to start my site without installed application. > But the admin give me always the same problem. > > I have already broken two keyboards trying to risolve the problem :) > > Have you another suggestion ? nope, sorry!... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Problem authenticating static content in Apache
I've got a working Django webapp that I'm happy with, running under mod_python, but I need to authenticate some static content served from Apache. The relevent part of my apache config looks like this: AuthType basic AuthName "attachments" Require valid-user SetEnv DJANGO_SETTINGS_MODULE file.settings PythonOption DJANGO_SETTINGS_MODULE file.settings PythonPath "['/home/jacob/dp1'] + sys.path" PythonAuthenHandler django.contrib.auth.handlers.modpython PythonDebug On The first time I request a file under that location I get this exception: Mod_python error: "PythonAuthenHandler django.contrib.auth.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/contrib/auth/handlers/modpython.py", line 24, in authenhandler from django.contrib.auth.models import User File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/contrib/auth/models.py", line 3, in ? from django.contrib.contenttypes.models import ContentType File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/contrib/contenttypes/models.py", line 22, in ? class ContentType(models.Model): File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/base.py", line 30, in __new__ new_class.add_to_class('_meta', Options(attrs.pop('Meta', None))) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/base.py", line 121, in add_to_class value.contribute_to_class(cls, name) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/models/options.py", line 53, in contribute_to_class setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', self.verbose_name + 's')) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/utils/functional.py", line 42, in __wrapper__ res = self.__func(*self.__args, **self.__kw) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/utils/translation.py", line 256, in gettext _default = translation(settings.LANGUAGE_CODE) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/utils/translation.py", line 184, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/utils/translation.py", line 167, in _fetch app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:]) AttributeError: 'module' object has no attribute 'auth' -- All subsequent requests (until I restart apache) throw this exception: Mod_python error: "PythonAuthenHandler django.contrib.auth.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/contrib/auth/handlers/modpython.py", line 24, in authenhandler from django.contrib.auth.models import User ImportError: cannot import name User I *can* import User from the command line like this: $ python Python 2.3.5 (#2, Sep 4 2005, 22:01:42) [GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from django.contrib.auth.models import User >>> - Without the PythonOption entry (just relying on modpython's SetEnv setting) I get this: Mod_python error: "PythonAuthenHandler django.contrib.auth.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/contrib/auth/handlers/modpython.py", line 24, in authenhandler from django.contrib.auth.models import User File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/contrib/auth/models.py", line 2, in ? from django.db import backend, connection, models File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/__init__.py", line 7, in ? if not settings.DATABASE_ENGINE: File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/conf/__init__.py", line 28, in __getattr__ self._import_settings() File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/conf/__init__.py", line 53, in _import_settings raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined. Am I missing something obvious? I'm running this under apache-2.0.54-5 and modpython-3.1.3-3 on a debian 3.1 system. Thanks! Jacob
Re: Errors using django.contrib.*.view
I suppose answering my own question shows that I was being a dolt ... which I was ... anyway this was just that I had forgotten about the prefix in urls.py ... ok .. so that works now, but it then causes an error with importing django.contrib.syndication.views.py where it tries to import django.contrib.syndication.views.feed .. Removing that line seems to fix it. Perhaps it is left over from a prior refactor? Cheers, Ed --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Am Dienstag, 27. Juni 2006 19:25 schrieb [EMAIL PROTECTED]: > Clear the cookies in your browser and the problem will go away. unfortunately that won't solve this problem - possibly another one ;) -- cheers, Nikl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Sniffing around django
Tom, Arthur, thanks a lot. I was infected with java container things. I'm checking citated docs. (I thought after some reading, middleware will be an answer, so i'll checking middleware too :) Anna _ Teljes körű pénzügyi ügyintézés és hiteligénylés a nap 24 órájában interneten keresztül! Számlavezetési díj mindössze havi 490 Ft! [origo] klikkbank mikrovállalati számlacsomag http://www.klikkbank.hu/vallalati/termekek/szamlacsomag/index.html --~--~-~--~~~---~--~~ Azért kapta ezt a levelet, mert feliratkozott a Google csoportok "Django users" csoport A témához való hozzászóláshoz küldjön egy emailt a következő címre django-users@googlegroups.com Ahhoz, hogy leiratkozzon erről a csoportról. küldjön egy e-mailt a [EMAIL PROTECTED] További információkért látogassa meg a csoport weblapját, itt: http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: admin connection mysql problem
Thanks for the answer :) I have tries to start my site without installed application. But the admin give me always the same problem. I have already broken two keyboards trying to risolve the problem :) Have you another suggestion ? > > Oh well, sorry my suggestion didn't help. > > A brute force way, if nobody else can help, would be to remove classes > one at a time from your model until the admin site works again. Narrow > down and then isolate the problem code, and then stare at it for a real > long time... > > John > > Patrick wrote: >> Thx john i have checked the spelling of every field listed in Admin >> class but the error was always there. >> >> Patrick >> John DeRosa wrote: >>> When I've seen messages similar to this, it's usually because an >>> identifier in the meta.Admin list_display list was not defined as a >>> field in the class. A good place to start would be to check the >>> spelling of every field listed in meta.Admin. >>> >>> John >>> >>> Patrick wrote: >>> Hi, when i go in my admin site (http://basetta.pupazzo.org/admin) I recieve always this Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", line 161, in handler return ModPythonHandler()(req) File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", line 137, in __call__ response = middleware_method(request, response) File "/usr/lib/python2.3/site-packages/django/contrib/sessions/middleware.py", line 81, in process_response session_key = request.session.session_key or Session.objects.get_new_session_key() File "/usr/lib/python2.3/site-packages/django/contrib/sessions/models.py", line 21, in get_new_session_key self.get(session_key=session_key) File "/usr/lib/python2.3/site-packages/django/db/models/manager.py", line 70, in get return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 202, in get obj_list = list(clone) File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 94, in __iter__ return iter(self._get_data()) File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 412, in _get_data self._result_cache = list(self.iterator()) File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line 161, in iterator cursor = connection.cursor() File "/usr/lib/python2.3/site-packages/django/db/backends/mysql/base.py", line 90, in cursor self.connection = Database.connect(**kwargs) File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 66, in Connect return Connection(*args, **kwargs) File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 151, in __init__ self.converter[types.StringType] = string_literal TypeError: object does not support item assignment but I canno't understand why. Have you some suggestions to give ? ciao ciao Patrick >>> >>> >> >> > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Generic relations and tags
hi Jay, IMO, you will have to do the unique contrain in the db level, here is the tagging model stuff I'm working on: class Tag(models.Model): name = models.CharField(maxlength=40, unique=True, db_index=True) invisible = models.NullBooleanField(default=False) def __str__(self): return self.name class Admin: pass class ObjectTag(models.Model): # an object may has many tags (no duplicate) # a tag could be applied to many objects content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField(_('object ID')) tag = models.ForeignKey(Tag) content_object = models.GenericForeignKey() class Meta: db_table = "tagging_object_tag" # a tag should be applied to an object for ONCE unique_together = (('content_type', 'object_id', 'tag',),) class UserObjectTag(models.Model): # the action of "apply a tag to an object" may be done by many users # a user could do many times of the action "apply a tag to an object" user = models.ForeignKey(User) object_tag = models.ForeignKey(ObjectTag) class Meta: db_table = "tagging_user_object_tag" # a user may apply a tag to an object for ONCE unique_together = (('user', 'object_tag',),) Let me know if there is anything wrong :) - Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Clear the cookies in your browser and the problem will go away. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: render to screen and dynamic file
On 6/26/06, Luis P. Mendes <[EMAIL PROTECTED]> wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > > Ok, I *think* I understand your problem a bit better. > > > > One thing you can do is store some information (filename, or > > something) in the session object for the user. Then it doesn't matter > > how long it takes for the user to press the button (unless of course > > they wait days, and expire the cookie). > > > Thank you for your answer. > > Would you mind sending me some link where such an example is > implemented, if possible? > > It's easier to code with an example. What do you need to see? How to write AJAX code, or how to store information in a session? I don't really have any links on how to do AJAX in Django (you can search through the mailing list, there have been some threads in the past). Storing stuff in sessions is relatively easy, and documented nicely in the main docs. To store something in a session, you just do: request.session["some_key"] = some_data Where 'some_key' is any key you want, and some_data is the data you want to store. I've done this myself in the past by generating a temporary file in one view (using Python's tempfile module to make sure it's unique), and storing it in the session. Then in another view (say, a view that gets called when the user presses a button) I can pull the filename out of the user's session. Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Generic relations and tags
So I'm now trying the new generic relations out for tags, much like the example in the documentation. The problem I'm having is doing a filter() to get a QuerySet of tags with unique names. Any thoughts on this? If two different objects are both given a tag "foo", there will be two tags in the system that have 'foo' as their 'tag' value. The only way I can think of doing this so far is to manually pull all the results out of a QuerySet, and use Python to figure out all the unique tag names. And that's ok, but it doesn't fit too nicely with the generic views (particularly object_list, when I just want a list of all the tag names in the system). Jay P. . --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Sniffing around django
On 6/27/06, Tom Tobin <[EMAIL PROTECTED]> wrote: > On 6/27/06, toth anna <[EMAIL PROTECTED]> wrote: > > > > Tom Tobin <[EMAIL PROTECTED]>: > > > You should be able to get the behavior you want by > > overriding the > > > save() method on your models. > > > > Is there any usable examples somewhere for me? > > Here's the general idea: > > http://www.djangoproject.com/documentation/models/save_delete_hooks/ > > In the save() method, place whatever logic you want to run before you > call the "real" save() via super(). Argh. I *really* have to keep better track of which list I'm posting/replying to; this thread belongs on django-users. :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Sniffing around django
In your model, overide the save method : def save(self): # get number of objects maxNumber = 5 current = MyModel.objects.all().count() if current < maxNumber: super(MyModel, self).save() #you can either pass - object won't be saved, or raise an exception cheers, arthur --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Checking For Existing Rows
Tyson Tate wrote: > However, raising an exception on "success" irks the part of me that > studied computer science for 3 years, so I'm wondering if anyone > knows of any other ways I might be able to achieve the above in a > better way. Compared to other languages, exception in python are very cheap operations. On C level, the function just returns a null pointer instead of a PyObject pointer and setting the two stack values for exception type and value isn't expensive eighter. In fact, it's so cheap that functions like has_key just try to access the value or return 0 on exception :) kindly regards Daniel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: render to screen and dynamic file
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Ok, I *think* I understand your problem a bit better. > > One thing you can do is store some information (filename, or > something) in the session object for the user. Then it doesn't matter > how long it takes for the user to press the button (unless of course > they wait days, and expire the cookie). > Thank you for your answer. Would you mind sending me some link where such an example is implemented, if possible? It's easier to code with an example. Luis P. Mendes -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEoGZpHn4UHCY8rB8RAgDQAJsEv4gdh1PDadZyWseMb2wKKMze5QCfUPGY 0INvFwf9wNfTdcHoxacSxfU= =D05r -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Errors using django.contrib.*.view
I am trying to add syndication support to a django project and it seems to have trouble getting the view from django.contrib.syndication.view per the url.py setting ... I keep getting this error: Could not import listmgr.lister.views.django.contrib.syndication.views. Error was: No module named django.contrib.syndication.views my url.py for this is: ... (r'^feeds/(?P.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}), ... Do I need to add django.contrib.syndications.views somewhere? I am running python 2.3 and the latest django brought down again from svn this am... It seems lke it things the view is in my project ... but of course it is django ... help ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
> I've heard that the problem might be related to md5 hashing (someone > just recently posted it here in the groups with the same error > message). I looked at the django code and that where that error message > is thrown and it seemed to confirm that, but I don't know why this > happens. simply try generating the reference hashes provided at the end of the md5 rfc[1] within a django-view - if they are not calculated correctly, you might want to switch from md5 to sha for a quick workaround and possibly follow the thread on the modpy mailinglist[2]. another solution might be something along the lines of the patch I posted earlier[3] - but of course, I don't know whether or when this will make it in into django ;) [1] http://www.ietf.org/rfc/rfc1321.txt [2] http://modpython.org/pipermail/mod_python/2006-June/021482.html [3] http://groups.google.com/group/django-users/browse_thread/thread/eeb44c894342d6f7/4b951b6d3a8644dd -- cheers, Nikl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Is this really a bug or did I messup
http://code.djangoproject.com/ticket/2243 here admin is calling set on a m2m class Resource(models.Model): name = models.CharField(maxlength=200) class Admin: pass class Plan(models.Model): name = models.CharField(maxlength=200) class Admin: pass class Requirement(models.Model): plan=models.ForeignKey(Plan,edit_inline=models.TABULAR) res = models.ManyToManyField(Resource) name = models.CharField(maxlength=200,core=True) Traceback (most recent call last): File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" in _checklogin 54. return view_func(request, *args, **kwargs) File "/usr/local/lib/python2.4/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 40. response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.4/site-packages/django/contrib/admin/views/main.py" in add_stage 257. new_object = manipulator.save(new_data) File "/usr/local/lib/python2.4/site-packages/django/db/models/manipulators.py" in save 218. was_changed = getattr(new_rel_obj, 'set_%s' % f.name)(rel_new_data[f.attname]) AttributeError at /sd/admin/vuln_crud/vulnerability/add/ 'Requirement' object has no attribute 'set_res' from django.db import models --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Sniffing around django
On 6/27/06, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > > On Jun 27, 2006, at 9:58 AM, toth anna wrote: > > I'm working on my thesis in our academy (i have to > > implement, too). > > Searching for an enviroment, i found django, and it looks > > very nice. > > After reading tutorial, i have some questions (and more to > > come...:) before i fall in love with it. > > > > Is there any (elegant) opportunity for a "container level > > logic". For example, there can be only 5 from a specific > > type of item, and inserting a new, we have to delete oldest > > object. > > Or when saving an object, container "splits" it, and creates > > two instead (from my example, if "date period" object > > contains a year boundary, i have to split it), without > > affecting "caller". > > > > Thanks for your help, > > > > Anna > > This question is best asked on django-users; I'm redirecting this > thread there. > > Jacob Oops, that's what I get for having Gmail dump both django-dev and django-users into the same label. :p My reply on django-dev was a one-liner: "You should be able to get the behavior you want by overriding the save() method on your models." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Sniffing around django
On Jun 27, 2006, at 9:58 AM, toth anna wrote: > I'm working on my thesis in our academy (i have to > implement, too). > Searching for an enviroment, i found django, and it looks > very nice. > After reading tutorial, i have some questions (and more to > come...:) before i fall in love with it. > > Is there any (elegant) opportunity for a "container level > logic". For example, there can be only 5 from a specific > type of item, and inserting a new, we have to delete oldest > object. > Or when saving an object, container "splits" it, and creates > two instead (from my example, if "date period" object > contains a year boundary, i have to split it), without > affecting "caller". > > Thanks for your help, > > Anna This question is best asked on django-users; I'm redirecting this thread there. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
On 6/27/06, Patrick J. Anderson <[EMAIL PROTECTED]> wrote: > > I've heard that the problem might be related to md5 hashing (someone > just recently posted it here in the groups with the same error > message). I suspect that it is. I've run into the same problem when I inadvertently changed the SECRET_KEY setting. Joseph --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Is it possible to do this from templates?
On 6/27/06, PythonistL <[EMAIL PROTECTED]> wrote: > > Hi, > Is it possible to test ,if an image exists, from a template? > To explain: > Let's suppose in my template I use > > > and {{ImageName}} is a picture that can exists but it needn't. > But if it does not exist, then I will receive an ugly picture in my > view (HTML)result. > So, I test that in my view but it would be better if I could test that > directly from my template > Thank you for help > L. You can always write a custom template filter that could check that pretty easily. Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: SuspiciousOperation: User tampered with session cookie
Hmm, I haven't changed domains. I simply took my previous setup on Fedora Core 5 with apache+mod_python and put it on Ubuntu Dapper with apache+mod_python. I've heard that the problem might be related to md5 hashing (someone just recently posted it here in the groups with the same error message). I looked at the django code and that where that error message is thrown and it seemed to confirm that, but I don't know why this happens. Could there be a bug with mod_python? I simply don't know, but would appreciate someone more experienced looking into it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Is it possible to do this from templates?
Hi, Is it possible to test ,if an image exists, from a template? To explain: Let's suppose in my template I use and {{ImageName}} is a picture that can exists but it needn't. But if it does not exist, then I will receive an ugly picture in my view (HTML)result. So, I test that in my view but it would be better if I could test that directly from my template Thank you for help L. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Repetitive background tasks
On 6/27/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Mon, 2006-06-26 at 13:28 -0700, Tyson Tate wrote: > > I've found a better solution with signals and the dispatcher. The > > essence is that you raise a signal every time someone views the > > relevant page, for instance, a "Recent Flickr Photos" page. In the > > relevant models.py file, you'll have attached a function call to be > > called on the raising of that signal. That function should check when > > the last time it was run, if it was run more than X minutes ago, have > > it call the relevant Flickr synchronization code, or whatever else > > you want it to do. > > Not a good idea if the process takes any significant amount of time to > run (such as, for example, retrieving things of the Internet). It will > block the response back to the user. You could though have a page that sends an XMLHTTPRequest to a different view, which can do the processing. Then the user won't experience any blocking at all. Jay P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Anyone got PyTextile?
Thomas Ashelford wrote: > I've been trying to source a copy of PyTextile 1.3 to use in a Django > application I'm building, but the dealmeida.net server is down. Is > there any kind soul out there who could email a copy at > thomas-at-ether.com.au? Look at Cheeseshop for pytextile-mirror. Cheers Jarek Zgoda --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: generating md5-hashes in modpython fails
I forgot to append this file... -- cheers, Nikl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~--- hashes.py Description: application/python
Re: Adding search functionality
Works like a charm! Thanks a lot! -Kristoffer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
RE: Time Tracking Tool
I thought I saw something like this on sourceforge -Original Message- From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED] Behalf Of Ian Holsman Sent: Tuesday, June 27, 2006 6:26 AM To: django-users@googlegroups.com Subject: Re: Time Tracking Tool Importance: Low On 27/06/2006, at 6:48 AM, Jos Yule wrote: > > I'm in the prototype phase for designing a time tracking/invoicing > tool > for my small business. First i'd like to know if anyone has already > done this kind of thing? > > If not, i'd like to make something available to other looking for this > kind of functionality. > > I should note that this _IS NOT_ for planning or project management. > Its just a time entry, reporting and invoicing tool. > > Ok, here is what i've got so far, table wise: > > CLIENT - name, address, notes, etc. > PROJECT - name, description - high level > JOB - name, related to a project. (rate) > WORK - hours, date done, by (association to the django USER table). > I'm assuming WORK also is associated with JOB > So, i might have a 'new product page' JOB for the 'web site' PROJECT > for 'wizbang' CLIENT. > > I'd then do WORK, which is associated to a JOB. The JOB currently has > the Rate ($/hr). that OK for small stuff, but if you have 2 people on a JOB it will fall down. > > I also have an INVOICE table to which each WORK row is associated. you should probably associate it with the CLIENT, as the client will probably want a single invoice for the time period detailing the work being done overall (but your client may be different) > > I'm not really happy with the INVOICE and WORK associations, or how a > JOB has the rate. I've also just hacked on the django USER association > to WORK. allow a invoice to over-ride the rate. > > It works for now, but in looking to make it (possibly) usable for a > wider audience, what things would you change or want to see added? > Don't use the built-in USER? Where should the Rate be stored? What > other var's would you want to have tracked (keeping in mind this is > trying to be a small simple app)? features ? for me multi-currency and PDF invoice generation. but you may just want to use SQL-ledger of OFBIZ (or quickbooks) they are pretty easy to use, and cheaper than writing it yourself. regards Ian > > I know that reports need to go in too, but that can be done once the > schema is defined... > > Thanks for any suggestions, hints and comments. > > jos > > > > --- The information contained in this message may be privileged and / or confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. --- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
generating md5-hashes in modpython fails
hi all, for some (up to now) unknown reasons the generation of md5-hashes fails in modpython (for me and at least one other user on irc). I discovered this bug while switching a django-setup from the builtin dev-server to modpython: it complained that I had tampered with the session cookies - which I didn't ;) the session ids looked a little unusual: all hashes started with 16 leading zeros. So next, I tried generating md5-hashes in django and they also had the leading zeros PLUS when generating a couple of hashes for different strings in one request the resulting hashes were all the same. After that I tested md5 hash generation in "plain" modpy - which had the same problems. the odd thing is: using the md5-module in "regular" python works totally fine! since this clearly seems to be a modpy issue, there's a thread on the modpy mailinglist: http://modpython.org/pipermail/mod_python/2006-June/021482.html note that, there already have been confirmations that this is not a general modpython issue. the first workaround was to replace md5 with sha - but since that can hardly be called a solution, I propose that the use of hashing algorithms should be "uncoupled" from the actual implementation used. the appended diff might be a start of into that direction, but certainly might need some clean up ;) -- cheers, Nikl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~--- Index: conf/global_settings.py === --- conf/global_settings.py (revision 3212) +++ conf/global_settings.py (working copy) @@ -221,6 +221,9 @@ # Hint: you really don't! TRANSACTIONS_MANAGED = False +# Which hashing algorithm do you prefer? (see django.util.hashes for available algorithms) +FAVORITE_HASH_ALGO = "md5" + ## # MIDDLEWARE # ## Index: contrib/sessions/models.py === --- contrib/sessions/models.py (revision 3212) +++ contrib/sessions/models.py (working copy) @@ -1,6 +1,7 @@ -import base64, md5, random, sys +import base64, random, sys import cPickle as pickle from django.db import models +from django.utils.hashes import hash from django.utils.translation import gettext_lazy as _ from django.conf import settings @@ -8,15 +9,15 @@ def encode(self, session_dict): "Returns the given session dictionary pickled and encoded as a string." pickled = pickle.dumps(session_dict) -pickled_md5 = md5.new(pickled + settings.SECRET_KEY).hexdigest() -return base64.encodestring(pickled + pickled_md5) +pickled_hash = hash.new(pickled + settings.SECRET_KEY).hexdigest() +return base64.encodestring(pickled + pickled_hash) def get_new_session_key(self): "Returns session key that isn't being used." # The random module is seeded when this Apache child is created. # Use person_id and SECRET_KEY as added salt. while 1: -session_key = md5.new(str(random.randint(0, sys.maxint - 1)) + str(random.randint(0, sys.maxint - 1)) + settings.SECRET_KEY).hexdigest() +session_key = hash.new(str(random.randint(0, sys.maxint - 1)) + str(random.randint(0, sys.maxint - 1)) + settings.SECRET_KEY).hexdigest() try: self.get(session_key=session_key) except self.model.DoesNotExist: @@ -49,8 +50,8 @@ def get_decoded(self): encoded_data = base64.decodestring(self.session_data) -pickled, tamper_check = encoded_data[:-32], encoded_data[-32:] -if md5.new(pickled + settings.SECRET_KEY).hexdigest() != tamper_check: +pickled, tamper_check = encoded_data[:hash.digest_size*-2], encoded_data[hash.digest_size*-2:] +if hash.new(pickled + settings.SECRET_KEY).hexdigest() != tamper_check: from django.core.exceptions import SuspiciousOperation raise SuspiciousOperation, "User tampered with session cookie." try: Index: contrib/admin/views/decorators.py === --- contrib/admin/views/decorators.py (revision 3212) +++ contrib/admin/views/decorators.py (working copy) @@ -2,8 +2,9 @@ from django.conf import settings from django.contrib.auth.models import User, SESSION_KEY from django.shortcuts import render_to_response +from django.utils.hashes import hash from django.utils.translation import gettext_lazy -import base64, datetime, md5 +import base64, datetime import cPickle as pickle ERROR_MESSAGE = gettext_lazy("Please enter a correct username
Re: Repetitive background tasks
On Mon, 2006-06-26 at 13:28 -0700, Tyson Tate wrote: > > On Jun 26, 2006, at 12:43 PM, Glenn Tenney wrote: > > > > [...] > > 2) Also within your application, write a global function that (a) > > immediately checks to see if it's the first time it's invoked each day > > (or whatever interval), and then, if it is the first time, (b) does > > all of the repetitive tasks... This translates to: the first click > > within the desired interval automatically performs the pending > > repetitive tasks. Note: this is not always a good solution (but can > > sometimes be fine), since you might have tasks that need to be done > > every interval even if no one clicks your site, or the tasks run a > > long time, etc. This can be combined with #1 above in that the URL in > > #1 above would only need to be some regular URL into your application > > since ANY click to your application will do the repetitive task once > > each interval. [...] > > I've found a better solution with signals and the dispatcher. The > essence is that you raise a signal every time someone views the > relevant page, for instance, a "Recent Flickr Photos" page. In the > relevant models.py file, you'll have attached a function call to be > called on the raising of that signal. That function should check when > the last time it was run, if it was run more than X minutes ago, have > it call the relevant Flickr synchronization code, or whatever else > you want it to do. Not a good idea if the process takes any significant amount of time to run (such as, for example, retrieving things of the Internet). It will block the response back to the user. Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Adding search functionality
Hi, It's not a "copy/paste" code. As I told you, it comes from the admin view. The self correspond to a more complex construct in the admin. You can find the full code here: \django\contrib\admin\views\main.py line 712 But it's not easy to understand at first sight. But I think the problem is that you are programming a view, don't you? In that case I think you can not simply return a QuerySet. You must return a render_to_response or something like that. Try to pass a render_to_response with your results in the context dictionary, something like: return render_to_response('blog/detail.html', { 'search': other_qs, } Hope it helps. G On 6/27/06, Kristoffer <[EMAIL PROTECTED]> wrote: > > Thank you, I have upgraded to 0.9.5 now. > Still can't get it to work, though. What does "self" refer to in > "other_qs = QuerySet(self.model)" ? > I changed it to Document, my class that represents an article: > > def search(request): > >query = request.POST['query'] >or_query=Q() >search_fields = ['title', 'body'] > >if query: >for bit in query.split(): >or_queries = [Q(**{'%s__icontains' % field_name: bit}) > for > field_name in search_fields] >other_qs = QuerySet(Document) >other_qs = other_qs.filter(reduce(operator.or_, > or_queries)) >return other_qs > > This gives me the following traceback: > > Traceback (most recent call last): > > File > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/servers/basehttp.py", > line 272, in run >self.result = application(self.environ, self.start_response) > > File > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/servers/basehttp.py", > line 615, in __call__ >return self.application(environ, start_response) > > File > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/wsgi.py", > line 150, in __call__ >response = middleware_method(request, response) > > File > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/sessions/middleware.py", > line 74, in process_response >patch_vary_headers(response, ('Cookie',)) > > File > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/utils/cache.py", > line 104, in patch_vary_headers >if response.has_header('Vary'): > > AttributeError: 'QuerySet' object has no attribute 'has_header' > > Any suggestions? > Thanks, > Kristoffer > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Time Tracking Tool
Thanks, i'll check those two packages out. I have the NIH syndrome down pretty good. ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Checking For Existing Rows
You could just check the count of that many items (since its unique it should always be 1 or 0): if Photo.objects.filter(flickr_id=photo("id")).count() == 0: # create the object ... But its my understanding that Python exceptions are not as heavy weight as they are in languages like C++/Java/C# so not only is either way probably fine, the exception approach is actually fairly common in Python. But I understand your discomfort - I had always taught myself (pre Python) to only use exceptions for exceptional cases, i.e. things you didn't expect to happen. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Adding search functionality
Thank you, I have upgraded to 0.9.5 now. Still can't get it to work, though. What does "self" refer to in "other_qs = QuerySet(self.model)" ? I changed it to Document, my class that represents an article: def search(request): query = request.POST['query'] or_query=Q() search_fields = ['title', 'body'] if query: for bit in query.split(): or_queries = [Q(**{'%s__icontains' % field_name: bit}) for field_name in search_fields] other_qs = QuerySet(Document) other_qs = other_qs.filter(reduce(operator.or_, or_queries)) return other_qs This gives me the following traceback: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/servers/basehttp.py", line 272, in run self.result = application(self.environ, self.start_response) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/servers/basehttp.py", line 615, in __call__ return self.application(environ, start_response) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/wsgi.py", line 150, in __call__ response = middleware_method(request, response) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/sessions/middleware.py", line 74, in process_response patch_vary_headers(response, ('Cookie',)) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/utils/cache.py", line 104, in patch_vary_headers if response.has_header('Vary'): AttributeError: 'QuerySet' object has no attribute 'has_header' Any suggestions? Thanks, Kristoffer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Checking For Existing Rows
http://www.djangoproject.com/documentation/models/get_or_create/ ? but yeah.. besides from using get_or_create, the exception route is probably the easiest route. On 27/06/2006, at 4:58 PM, Tyson Tate wrote: > > In one of my apps, I need to check and see if a row already exists > based on a unique field. Currently, I'm doing something like the > following: > > > for photo in photos: > try: > row = Photo.objects.get(flickr_id=photo("id")) > # Raise exception if photo doesn't exist in our DB yet > except ObjectDoesNotExist: > [[[Make the object, etc]]] > > > However, raising an exception on "success" irks the part of me that > studied computer science for 3 years, so I'm wondering if anyone > knows of any other ways I might be able to achieve the above in a > better way. > > Thanks, > Tyson > > -- > Tyson Tate > - CalPoly Graphic Design Student > - Work: Graphic Designer (CalPoly Library) > - Play: Mustang Band, CalPoly Triathlon Team, Kappa Kappa Psi (Iota > Pi) > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Time Tracking Tool
On 27/06/2006, at 6:48 AM, Jos Yule wrote: > > I'm in the prototype phase for designing a time tracking/invoicing > tool > for my small business. First i'd like to know if anyone has already > done this kind of thing? > > If not, i'd like to make something available to other looking for this > kind of functionality. > > I should note that this _IS NOT_ for planning or project management. > Its just a time entry, reporting and invoicing tool. > > Ok, here is what i've got so far, table wise: > > CLIENT - name, address, notes, etc. > PROJECT - name, description - high level > JOB - name, related to a project. (rate) > WORK - hours, date done, by (association to the django USER table). > I'm assuming WORK also is associated with JOB > So, i might have a 'new product page' JOB for the 'web site' PROJECT > for 'wizbang' CLIENT. > > I'd then do WORK, which is associated to a JOB. The JOB currently has > the Rate ($/hr). that OK for small stuff, but if you have 2 people on a JOB it will fall down. > > I also have an INVOICE table to which each WORK row is associated. you should probably associate it with the CLIENT, as the client will probably want a single invoice for the time period detailing the work being done overall (but your client may be different) > > I'm not really happy with the INVOICE and WORK associations, or how a > JOB has the rate. I've also just hacked on the django USER association > to WORK. allow a invoice to over-ride the rate. > > It works for now, but in looking to make it (possibly) usable for a > wider audience, what things would you change or want to see added? > Don't use the built-in USER? Where should the Rate be stored? What > other var's would you want to have tracked (keeping in mind this is > trying to be a small simple app)? features ? for me multi-currency and PDF invoice generation. but you may just want to use SQL-ledger of OFBIZ (or quickbooks) they are pretty easy to use, and cheaper than writing it yourself. regards Ian > > I know that reports need to go in too, but that can be done once the > schema is defined... > > Thanks for any suggestions, hints and comments. > > jos > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Model vanishes from Admin
Okay what solved my problem was removing imports of my models from urls.py. I had a few generic view wrappers that were short so I had just defined them in urls.py for now and that was causing a problem when django was launched from fastcgi or mod_python but not django-admin.py runserver. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: New vim files for Django available
That's nice!Didn't notice vim 7.0 had django syntax highlighting! Good work.Cheers,Marc.On 6/27/06, Jeroen Ruigrok van der Werven < [EMAIL PROTECTED]> wrote:At http://www.vim.org/scripts/script.php?script_id=1487 you can findthe latest versions (1.02, released 2006-06-26) of Dave Hodder'sdjango.vim and htmldjango.vim.--Jeroen Ruigrok van der Werven --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Maintaining foreign key reference when foreign object gets deleted
mohan wrote: > Hi, > > I have the following 3 models with one model having a foreign key > reference to another model. > > class DeliveryBatch(models.Model): > delivered_to = models.ForeignKey(Centre) > ... > > class Centre(models.Model): > is_deleted = models.BooleanField(default=false) > ... > > class CentreLog(models.Model): >"""contains all attributes of Centre together with > last_modified_time, user and corresponding action.""" > ... > > The problem is, a Centre referred to by a DeliveryBatch may get deleted > in the future. Then the foreign key reference of the DeliveryBatch gets > invalid. Django even goes a step further and deletes the corresponding > DeliveryBatch. But this is undesirable. The usual approach is to set delivered_to to NULL (or, None) before deleting it. Michael --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: How to select distinct rows?
I don't think GROUP BY is part of the Django ORM, but you can easily use raw SQL in a custom method to achieve this: http://www.djangoproject.com/documentation/models/custom_methods/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Adding search functionality
On 27 Jun 2006, at 08:53, Kristoffer wrote: > I can import Q with "from django.core.meta import Q", but I can't find > QuerySet. Did it exist in version 0.91? No. QuerySet is part of the vastly superior magic-removal ORM, which was introduced in Django 0.9.5. There are instructions on upgrading from 0.9.1 here: http://code.djangoproject.com/wiki/RemovingTheMagic Cheers, Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Adding search functionality
Thank you very much for your help! This seems to be exactly what I would like to do! However, your source seems to be for another version of Django than I run (I have version 0.91) I can import Q with "from django.core.meta import Q", but I can't find QuerySet. Did it exist in version 0.91? Thanks, Kristoffer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: admin connection mysql problem
Now i have tried only the default admin page without any app and the results are the same John DeRosa wrote: > When I've seen messages similar to this, it's usually because an > identifier in the meta.Admin list_display list was not defined as a > field in the class. A good place to start would be to check the > spelling of every field listed in meta.Admin. > > John > > Patrick wrote: > >> Hi, >> when i go in my admin site (http://basetta.pupazzo.org/admin) >> I recieve always this >> >> Mod_python error: "PythonHandler django.core.handlers.modpython" >> >> Traceback (most recent call last): >> >> File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in >> HandlerDispatch >> result = object(req) >> >> File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", >> line 161, in handler >> return ModPythonHandler()(req) >> >> File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", >> line 137, in __call__ >> response = middleware_method(request, response) >> >> File >> "/usr/lib/python2.3/site-packages/django/contrib/sessions/middleware.py", >> line 81, in process_response >> session_key = request.session.session_key or >> Session.objects.get_new_session_key() >> >> File "/usr/lib/python2.3/site-packages/django/contrib/sessions/models.py", >> line 21, in get_new_session_key >> self.get(session_key=session_key) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/manager.py", line >> 70, in get >> return self.get_query_set().get(*args, **kwargs) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 202, in get >> obj_list = list(clone) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 94, in __iter__ >> return iter(self._get_data()) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 412, in _get_data >> self._result_cache = list(self.iterator()) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 161, in iterator >> cursor = connection.cursor() >> >> File "/usr/lib/python2.3/site-packages/django/db/backends/mysql/base.py", >> line 90, in cursor >> self.connection = Database.connect(**kwargs) >> >> File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 66, in >> Connect >> return Connection(*args, **kwargs) >> >> File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 151, >> in __init__ >> self.converter[types.StringType] = string_literal >> >> TypeError: object does not support item assignment >> >> >> but I canno't understand why. >> >> Have you some suggestions to give ? >> >> ciao ciao >> Patrick >> >> > > > > > -- __ email:[EMAIL PROTECTED] http://patrick.pupazzo.org __ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
New vim files for Django available
At http://www.vim.org/scripts/script.php?script_id=1487 you can find the latest versions (1.02, released 2006-06-26) of Dave Hodder's django.vim and htmldjango.vim. -- Jeroen Ruigrok van der Werven --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Checking For Existing Rows
In one of my apps, I need to check and see if a row already exists based on a unique field. Currently, I'm doing something like the following: for photo in photos: try: row = Photo.objects.get(flickr_id=photo("id")) # Raise exception if photo doesn't exist in our DB yet except ObjectDoesNotExist: [[[Make the object, etc]]] However, raising an exception on "success" irks the part of me that studied computer science for 3 years, so I'm wondering if anyone knows of any other ways I might be able to achieve the above in a better way. Thanks, Tyson -- Tyson Tate - CalPoly Graphic Design Student - Work: Graphic Designer (CalPoly Library) - Play: Mustang Band, CalPoly Triathlon Team, Kappa Kappa Psi (Iota Pi) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: how to manually invlaid a cached view?
No, I can't invalidate the view cache. it looks that if directly use cache.set to store a cache. only one file would stored in file system(soppose using file based cache), but use @cache_page, there would be two file, one for header and another for content. On 6/27/06, Jay Parlar <[EMAIL PROTECTED]> wrote: On 6/26/06, Wei Litao <[EMAIL PROTECTED]> wrote:> I have checked the cache document, it said that an view can have an> @cache_page(60 * 15) decorator to store it on a cache, But it didn't say how > to fluch it. Is there some api to invalid a view cache manually? I want to> invalid some view cache when calling another view.Check the part of the cache document entitled "Low-level API" (http://www.djangoproject.com/documentation/cache/#the-low-level-cache-api)It looks like you can just import the 'cache' object, and call 'delete', passing in the URL you want to invalidate.Warning: I've not actually used the cache framework yet, so I might be wrong.Jay P.-- Sincerely,Wei Litao --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: admin connection mysql problem
Thx john i have checked the spelling of every field listed in Admin class but the error was always there. Patrick John DeRosa wrote: > When I've seen messages similar to this, it's usually because an > identifier in the meta.Admin list_display list was not defined as a > field in the class. A good place to start would be to check the > spelling of every field listed in meta.Admin. > > John > > Patrick wrote: > >> Hi, >> when i go in my admin site (http://basetta.pupazzo.org/admin) >> I recieve always this >> >> Mod_python error: "PythonHandler django.core.handlers.modpython" >> >> Traceback (most recent call last): >> >> File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in >> HandlerDispatch >> result = object(req) >> >> File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", >> line 161, in handler >> return ModPythonHandler()(req) >> >> File "/usr/lib/python2.3/site-packages/django/core/handlers/modpython.py", >> line 137, in __call__ >> response = middleware_method(request, response) >> >> File >> "/usr/lib/python2.3/site-packages/django/contrib/sessions/middleware.py", >> line 81, in process_response >> session_key = request.session.session_key or >> Session.objects.get_new_session_key() >> >> File "/usr/lib/python2.3/site-packages/django/contrib/sessions/models.py", >> line 21, in get_new_session_key >> self.get(session_key=session_key) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/manager.py", line >> 70, in get >> return self.get_query_set().get(*args, **kwargs) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 202, in get >> obj_list = list(clone) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 94, in __iter__ >> return iter(self._get_data()) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 412, in _get_data >> self._result_cache = list(self.iterator()) >> >> File "/usr/lib/python2.3/site-packages/django/db/models/query.py", line >> 161, in iterator >> cursor = connection.cursor() >> >> File "/usr/lib/python2.3/site-packages/django/db/backends/mysql/base.py", >> line 90, in cursor >> self.connection = Database.connect(**kwargs) >> >> File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 66, in >> Connect >> return Connection(*args, **kwargs) >> >> File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 151, >> in __init__ >> self.converter[types.StringType] = string_literal >> >> TypeError: object does not support item assignment >> >> >> but I canno't understand why. >> >> Have you some suggestions to give ? >> >> ciao ciao >> Patrick >> >> > > > > > -- __ email:[EMAIL PROTECTED] http://patrick.pupazzo.org __ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---