On Oct 6, 4:48 pm, Karen Tracey wrote:
> I showed it from the shell because that's easiest to demonstrate. But it
> also works for the model you have included here even from admin. If it's
> not working for the model you actually have then it is due to some
> difference between what you have po
On Tue, Oct 6, 2009 at 9:15 PM, Robert Field wrote:
>
> On Oct 6, 10:09 am, Karen Tracey wrote:
> >
> > Personally I'd look pretty closely at the need to store a value dependent
> on
> > the primary key in some other field of the model. Is this really
> absolutely
> > necessary?
> >
> > Karen
>
On Oct 6, 10:09 am, Karen Tracey wrote:
>
> Personally I'd look pretty closely at the need to store a value dependent on
> the primary key in some other field of the model. Is this really absolutely
> necessary?
>
> Karen
In relational models it's pretty standard to use the primary key as
the
On Tue, Oct 6, 2009 at 3:31 PM, Aaron wrote:
>
> On Oct 6, 4:20 pm, Karen Tracey wrote:
> > On Tue, Oct 6, 2009 at 2:49 PM, Aaron wrote:
> >
> > > Just tried it, like this:
> >
> > > class MyModel(models.Model):
> > >myfield = models.CharField(unique = True, blank = True, null =
> > > True)
On Oct 6, 4:20 pm, Karen Tracey wrote:
> On Tue, Oct 6, 2009 at 2:49 PM, Aaron wrote:
>
> > Just tried it, like this:
>
> > class MyModel(models.Model):
> > myfield = models.CharField(unique = True, blank = True, null =
> > True)
>
> That can't be right because this field is missing max_lengt
On Tue, Oct 6, 2009 at 2:49 PM, Aaron wrote:
>
> Just tried it, like this:
>
> class MyModel(models.Model):
>myfield = models.CharField(unique = True, blank = True, null =
> True)
>
>
That can't be right because this field is missing max_length.
>def save(self, force_insert = False, for
Just tried it, like this:
class MyModel(models.Model):
myfield = models.CharField(unique = True, blank = True, null =
True)
def save(self, force_insert = False, force_update = False):
if self.myfield == '':
self.myfield = None
super(MyModel, self).save(force_
On Oct 6, 2:56 pm, Daniel Roseman wrote:
> Does that field need to be unique on its own?
Yes it does. And I also don't want the clients of this model to know
that they could be accessing the model's ID when they access the field
in question.
I suppose what I could do is have the field be eithe
On Oct 6, 6:28 pm, Aaron wrote:
> On Oct 6, 2:09 pm, Karen Tracey wrote:
>
> > Yes, you'll have to save the change to the DB. But note if you were called
> > with force_insert=True you do not want to call the superclass save with
> > force_insert=True twice.
>
> OK. Would calling "super(MyMode
On Oct 6, 2:09 pm, Karen Tracey wrote:
> Yes, you'll have to save the change to the DB. But note if you were called
> with force_insert=True you do not want to call the superclass save with
> force_insert=True twice.
OK. Would calling "super(MyModel, self).save(False, force_update)" be
safe
On Tue, Oct 6, 2009 at 12:57 PM, Aaron wrote:
>
> On Oct 6, 1:30 pm, Karen Tracey wrote:
> > The only sure way to know what primary key is going to be assigned by the
> DB
> > is to actually save the object to the DB and see what got assigned.
>
> O.K. Now, when I get the ID after saving the obj
On Oct 6, 1:30 pm, Karen Tracey wrote:
> The only sure way to know what primary key is going to be assigned by the DB
> is to actually save the object to the DB and see what got assigned.
O.K. Now, when I get the ID after saving the object and perform some
logic on it, I'll want to store my resu
On Tue, Oct 6, 2009 at 12:05 PM, Aaron wrote:
>
> When saving a model, I need to be able to access its ID field like
> this:
>
> class MyModel:
>...
>def save(self, force_insert = False, force_update = False):
>v = self.id
># Do something with v
>
>super(MyModel, s
You could do something like this:
def save(self, force_insert=False, force_update=False):
# first save the model using the base class save method
super(MyModel, self).save(force_insert, force_update)
# then self will have an id set
v = self.id
On Tue, 2009-10-06 at
When saving a model, I need to be able to access its ID field like
this:
class MyModel:
...
def save(self, force_insert = False, force_update = False):
v = self.id
# Do something with v
super(MyModel, self).save(force_insert, force_update)
However, if the model i
15 matches
Mail list logo