Performing an action on model.save() but not on update

2010-04-23 Thread Jim N
Hi, I have overridden the default save() on a model so that I can update some counts every time a save occurs. Unfortunately, I don't want to perform these actions every time the model is updated, which seems to happen. Is there another approach I can take that distinguishes between save and upd

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Jim N
false depending on if > > > the object is being created or updated. Check out the post_save > > > documentation:http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.si... > > > > On Apr 23, 3:32 pm, Skylar Saveland wrote: > > > > > On Apr 23, 3:27 pm, Jim N wrote

Re: Performing an action on model.save() but not on update

2010-04-26 Thread Jim N
created: >         if instance.user: >             quser = instance.user.get_profile() >             quser.increment_answers() >         instance.question.increment_responses() > > post_save.connect(_hook_post_save_answer, sender=Answer) > > On Apr 23, 6:20 pm, Jim N wrote: &g

Serializing objects with a many-to-many reference

2010-03-02 Thread Jim N
Hi, I am writing a question-and-answer app which serializes data in JSON. I have Question, User, and Asking models. Asking is the many-to-many relationship table for Question and User, because the Asking relationship may be more complicated than it seems. (Several users may ask, and re-ask the s

Re: Serializing objects with a many-to-many reference

2010-03-03 Thread Jim N
uture reference though. It seems like this kind of thing must come up all the time. -Jim On Mar 2, 6:45 pm, Russell Keith-Magee wrote: > On Wed, Mar 3, 2010 at 12:46 AM, Jim N wrote: > > Hi, > > > I am writing a question-and-answer app which serializes data in JSON. > > I ha

Re: Serializing objects with a many-to-many reference

2010-03-03 Thread Jim N
I just came across manager methods in the docs: http://docs.djangoproject.com/en/dev/topics/db/managers/#adding-extra-manager-methods Could I have used these to create a seriallizable QuerySet, by defining, say, a with_user() method inside the Questions model? -Jim On Mar 3, 10:21 am, Jim N

basic django auth fails on valid user

2010-03-24 Thread Jim N
Hi, I am writing a basic login routine using django users. Here is the view: def login_result(request): username = request.POST['u'] password = request.POST['p'] logging.debug("look for user %s / %s" % (username, password)) user = authenticate(username=username, password=password)

Re: basic django auth fails on valid user

2010-03-24 Thread Jim N
`.`password`, [...] FROM `api_qotduser` INNER JOIN `auth_user` ON (`api_qotduser`.`user_ptr_id` = `auth_user`.`id`) WHERE `auth_user`.`username` = 'ricky' Thanks, Jim On Mar 24, 3:37 pm, Jim N wrote: > Hi, > > I am writing a basic login routine using django users. &

Re: basic django auth fails on valid user

2010-03-25 Thread Jim N
Thanks Tim, Yes, I just saw this. I was subclassing auth.User because I didn't know the right way to do it. Now I am on the right track. Just one thing I can't figure out. "When a user profile model has been defined and specified in this manner, each User object will have a method -- get_profi

Re: About extending User model

2010-03-25 Thread Jim N
On Mar 11, 1:03 pm, Tom Evans wrote: > On Thu, Mar 11, 2010 at 4:54 PM, russianbandit > wrote: > > I'm using UserProfile to add one field to my users. However, I know > > that I must explicitly create UserProfile for each new user that > > registers. So, I make a UserProfile upon registration. I

Re: About extending User model

2010-03-25 Thread Jim N
n need the stuff you can put in UserProfile if you > create him via the admin pages? > If he really needs it, tell him to register and then you go in an turn > his created account (in the admin) to a superuser or whatever you > need. > > On 25 Mar, 18:37, Jim N wrote: > &

Re: About extending User model

2010-03-26 Thread Jim N
On Mar 26, 1:39 pm, Carl Zmola wrote: > On 03/25/2010 02:37 PM, Jim N wrote: > > Very interesting, Tom. > > > I have inserted this code, substituting my profile model name > > (QotdUser) for UserProfile.  It does create a row in QotdUser, but the > > row is empty of

Re: About extending User model

2010-03-26 Thread Jim N
Carl, scratch my last message. It does work. Woot! Thanks very much. On Mar 26, 2:39 pm, Jim N wrote: > On Mar 26, 1:39 pm, Carl Zmola wrote: > > > > > > > On 03/25/2010 02:37 PM, Jim N wrote: > > > Very interesting, Tom. > > > > I have inserted

Complex Django query - filtering, joining a many-to-many table

2010-04-01 Thread Jim N
Hello Djanglers, I am using a named many-to-many table ("Asking") to join "Questions" to "Users". Asking has some fields I'd like to filter against. I now use a dictionary called filters: filters = {} if 'question' in request.GET: filters['text__icontains'] = request.GET['qu

Re: Complex Django query - filtering, joining a many-to-many table

2010-04-01 Thread Jim N
e'] > > seehttp://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o... > > Hht, > Nuno > > > > On Thu, Apr 1, 2010 at 3:09 PM, Jim N wrote: > > Hello Djanglers, > > > I am using a named many-to-many table ("Asking") to join &q

Dashboard plugin/widget development - create new post

2010-04-05 Thread Jim N
Hi List, I thought this would be easy at first. Maybe it is. I am developing a dashboard widget that creates a post. Trying to emulate what QuickPress does, only the title is from a select box, instead of text input. Here is the form. It points at wp-admin/post.php. I get redirected to edit.

please ignore: Re: Dashboard plugin/widget development - create new post

2010-04-05 Thread Jim N
Apologies - I posted this to the wrong group! On Apr 5, 12:23 pm, Jim N wrote: > Hi List, > > I thought this would be easy at first.  Maybe it is. > > I am developing a dashboard widget that creates a post.  Trying to > emulate what QuickPress does, only the title is from a sel

another many-to-many filtering question

2010-04-07 Thread Jim N
Hi All, I have a many-to-many relationship of User to Question through Asking. I want to get Questions that a given User has not asked yet. That is, Questions where there is no Asking record for a given User. I have the User's id. Models look like: class Question(models.Model): text = m

determining if a one-to-many relation exists

2010-04-12 Thread Jim N
Hi Djangoists, I have a model "question" which has a one-to-many relationship with "answer". class Question(models.Model): text = models.TextField() class Answer(models.Model): text = models.TextField() question = models.ForeignKey(Question) I can't figure out how to construct a fil

Re: determining if a one-to-many relation exists

2010-04-12 Thread Jim N
filtering questions on a number of parameters, such as text of the question. Thanks, Jim On Apr 12, 11:50 am, Jim N wrote: > Hi Djangoists, > > I have a model "question" which has a one-to-many relationship with > "answer". > > class Question(models.Model):

Re: determining if a one-to-many relation exists

2010-04-12 Thread Jim N
't exist. > > On Apr 12, 12:20 pm, Jim N wrote: > > > Just to clarify, I'm trying to filter questions that have an answer, > > but I don't know the particular answer.  I just want to determine > > whether or not an answer object ex