Hi, i need update a fields the other model i have FK relation
ok this is my code
ModelA(models.Model):
name=charfield(...)
field_count = integerfield()
.
ModelB(models.Model):
fk_name = FK(ModelA, related_name='models_a')
# other fields
def save(self, *args, **
I think the argument to the F object should be just the name of the field
on ModelA:
product.field_count = F('field_count') + 1
Other than that, there are a few weird things about the code, for example:
product = ModelA.objects.get(id=self.fk_name.id)
Why not just use
product = sel
Hi, @Vijay you suggestion not working no increment the field_count :/ any
other idea
Cheers
On Thu, Oct 16, 2014 at 2:44 PM, Vijay Khemlani wrote:
> I think the argument to the F object should be just the name of the field
> on ModelA:
>
> product.field_count = F('field_count') + 1
>
> Othe
Well, you can start trying by changing some lines, for example
product.field_count += 1
(I know it is less efficient and does not consider race conditions, but we
need to identify the problem)
You can also try executing the save without the update_fields param.
Finally, if you're using Django D
Hi,
Would this work?
ModelA.objects.filter(id=self.fk_name_id).update(field_count=F('field_count')
+ 1)
Collin
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
t
+Collin Thank this is working perfects :)
Cheers
On Thu, Oct 16, 2014 at 3:31 PM, Collin Anderson
wrote:
> Hi,
>
> Would this work?
>
> ModelA.objects.filter(id=self.fk_name_id).update(field_count=F('field_count')
> + 1)
>
> Collin
>
> --
> You received this message because you are subscribed
6 matches
Mail list logo