Thanks Eric, that worked like a charm. I've never got to use the update,
thus I had no idea of its existence, fair enough that is exactelly what I
needed.
Thank you very much, and other who have answered this thread.
Victor Lima
2010/1/16 Eric Chamberlain
>
> On Jan 15, 2010, at
On Jan 15, 2010, at 4:22 PM, Victor Loureiro Lima wrote:
> Here is the deal:
>
> class MyModel ( models.Model ):
> title = models.CharField( max_length = 100 )
> only_me = models.BooleanField( default = False )
>
> Question: Whats the proper way to guarantee that no matter how many
>
On Friday 15 January 2010 17:11:23 Victor Loureiro Lima wrote:
> I did exactelly that, instead of using id I used the slug, which is also
> unique, so I skipped it,
> but the problem still occurs. Either my logic is wrong, or some dumb
> mistake, but I think that wouldnt work either.
>
> Victor
On Friday 15 January 2010 17:08:06 Mike Ramirez wrote:
> Add in an if statement, one that while cycling through the only_me=True
> list, ignores the current model you're saving.
>
> def save(self):
> if self.only_me:
> only_me_true =
I did exactelly that, instead of using id I used the slug, which is also
unique, so I skipped it,
but the problem still occurs. Either my logic is wrong, or some dumb
mistake, but I think that wouldnt work either.
Victor Lima
2010/1/15 Mike Ramirez
> Add in an if
Add in an if statement, one that while cycling through the only_me=True list,
ignores the current model you're saving.
def save(self):
if self.only_me:
only_me_true = MyModel.objects.filter(only_me=True)
for obj in only_me_true:
I think that will not work,when I call the obj.save() I will inevitably
step again into my own save() method and the only_me wont be set as False
yet, thus the same problem would occur again and again until I get the
maximum depth error. I dont think thats an option, ahev you tested this
Hey Victor,
I can think that a trivial way (I am not sure if it is the best) to do that
is to overwrite the save() method of your model:
class MyModel(models.Model):
title = models.CharField(max_length=100)
only_me = models.Boolean(default=False)
def save(self):
if
Here is the deal:
class MyModel ( models.Model ):
title = models.CharField( max_length = 100 )
only_me = models.BooleanField( default = False )
Question: Whats the proper way to guarantee that no matter how many
MyModel's are available in the database, only one of them
will have the only_me
9 matches
Mail list logo