Re: Model save() weird behaviour

2009-07-22 Thread Phil

Thanks Brian,

'QWERTY' goes from the form entry here...but that's not important as
issue is located somewhere else, precisely save is called twice...
apologise for that

Cheers,
Philip

On Jul 21, 2:52 pm, Brian May  wrote:
> On Thu, Jul 16, 2009 at 04:09:36AM -0700, Phil wrote:
> >     defsave():
> >        # title is received from a form, say i've entered 'QWERTY'
> >         title1 =  str(self.title)
> >         self.fulltitle = title1
> >         #fulltitle = title = 'QWERTY'
> >         self.title = 'sampletext'
> >         super(Article, self).save()
>
> > after all i got:
> >         fulltitle = title = 'sampletext'
> > i was expecting to have:
> >         fulltitle =  'QWERTY'
> >         title = 'sampletext'
>
> Why should it do that?
>
> The only line containing QWERTY is commented out, and even if it wasn't
> commented out it does nothing. Maybe you meant to say:
>
> self.fulltitle = self.title = 'QWERTY'
>
> As such, what you have is:
>
> self.fulltitle = self.title
> self.title = 'sampletext'
> self.save()
>
> So the new value of self.fulltitle depends on what self.title previously was.
> --
> Brian May 
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model save() weird behaviour

2009-07-20 Thread Brian May

On Thu, Jul 16, 2009 at 04:09:36AM -0700, Phil wrote:
> def save():
># title is received from a form, say i've entered 'QWERTY'
> title1 =  str(self.title)
> self.fulltitle = title1
> #fulltitle = title = 'QWERTY'
> self.title = 'sampletext'
> super(Article, self).save()
> 
> after all i got:
> fulltitle = title = 'sampletext'
> i was expecting to have:
> fulltitle =  'QWERTY'
> title = 'sampletext'

Why should it do that?

The only line containing QWERTY is commented out, and even if it wasn't
commented out it does nothing. Maybe you meant to say:

self.fulltitle = self.title = 'QWERTY'

As such, what you have is:

self.fulltitle = self.title
self.title = 'sampletext'
self.save()

So the new value of self.fulltitle depends on what self.title previously was.
-- 
Brian May 

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model save() weird behaviour

2009-07-20 Thread Phil

anyone?
any ideas? :)

On Jul 17, 11:00 am, Phil  wrote:
> oh, sorry for that - exampling mistake, should be:
>
> class Page(models.Model):
>     title = models.CharField(_(u"Title"), max_length=50)
>     fulltitle = models.CharField(_(u"Full Title"), max_length=50)
> ...
>
>     defsave():
>        # title is received from a form, say i've entered 'QWERTY'
>         title1 =  str(self.title)
>         self.fulltitle = title1
>         #fulltitle = title = 'QWERTY'
>         self.title = 'sampletext'
>         super(Page, self).save()
>
> Thanks for that correction,
> Cheers,
> Phil
>
> On Jul 16, 9:50 pm, Karen Tracey  wrote:
>
>
>
> > On Thu, Jul 16, 2009 at 7:09 AM, Phil  wrote:
>
> > > Hi All,
>
> > > noticed an interesting behaviour in modelsave:
>
> > > class Page(models.Model):
> > >    title = models.CharField(_(u"Title"), max_length=50)
> > >    fulltitle = models.CharField(_(u"Full Title"), max_length=50)
> > > ...
>
> > >    defsave():
> > >       # title is received from a form, say i've entered 'QWERTY'
> > >        title1 =  str(self.title)
> > >        self.fulltitle = title1
> > >        #fulltitle = title = 'QWERTY'
> > >        self.title = 'sampletext'
> > >        super(Article, self).save()
>
> > That can't really be thesave() for Page because it's calling super(Article,
> > self)...?
>
> > Karen
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model save() weird behaviour

2009-07-16 Thread Phil

oh, sorry for that - exampling mistake, should be:

class Page(models.Model):
title = models.CharField(_(u"Title"), max_length=50)
fulltitle = models.CharField(_(u"Full Title"), max_length=50)
...

def save():
   # title is received from a form, say i've entered 'QWERTY'
title1 =  str(self.title)
self.fulltitle = title1
#fulltitle = title = 'QWERTY'
self.title = 'sampletext'
super(Page, self).save()


Thanks for that correction,
Cheers,
Phil

On Jul 16, 9:50 pm, Karen Tracey  wrote:
> On Thu, Jul 16, 2009 at 7:09 AM, Phil  wrote:
>
> > Hi All,
>
> > noticed an interesting behaviour in model save:
>
> > class Page(models.Model):
> >    title = models.CharField(_(u"Title"), max_length=50)
> >    fulltitle = models.CharField(_(u"Full Title"), max_length=50)
> > ...
>
> >    def save():
> >       # title is received from a form, say i've entered 'QWERTY'
> >        title1 =  str(self.title)
> >        self.fulltitle = title1
> >        #fulltitle = title = 'QWERTY'
> >        self.title = 'sampletext'
> >        super(Article, self).save()
>
> That can't really be the save() for Page because it's calling super(Article,
> self)...?
>
> Karen
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model save() weird behaviour

2009-07-16 Thread Karen Tracey
On Thu, Jul 16, 2009 at 7:09 AM, Phil  wrote:

>
> Hi All,
>
> noticed an interesting behaviour in model save:
>
> class Page(models.Model):
>title = models.CharField(_(u"Title"), max_length=50)
>fulltitle = models.CharField(_(u"Full Title"), max_length=50)
> ...
>
>def save():
>   # title is received from a form, say i've entered 'QWERTY'
>title1 =  str(self.title)
>self.fulltitle = title1
>#fulltitle = title = 'QWERTY'
>self.title = 'sampletext'
>super(Article, self).save()
>

That can't really be the save() for Page because it's calling super(Article,
self)...?

Karen

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model save() weird behaviour

2009-07-16 Thread Phil

Hi All,

noticed an interesting behaviour in model save:

class Page(models.Model):
title = models.CharField(_(u"Title"), max_length=50)
fulltitle = models.CharField(_(u"Full Title"), max_length=50)
...

def save():
   # title is received from a form, say i've entered 'QWERTY'
title1 =  str(self.title)
self.fulltitle = title1
#fulltitle = title = 'QWERTY'
self.title = 'sampletext'
super(Article, self).save()

after all i got:
fulltitle = title = 'sampletext'
i was expecting to have:
fulltitle =  'QWERTY'
title = 'sampletext'

so - does it mean that i pass reference to an existing object, not a
value? Do i miss some fundamental thing about Django? :)

Cheers
Phil

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---