0

I have this:

maxAux = Auxi.objects.all().aggregate(Max('nroAux'))

Then I need to add +1 to its value, but doing:

maxAux = maxAux+1

will throw an error since aggregate(max returns a string value like {'nroAux__max': 5} and I only need this number 5.

Please avoid asnwering about id or django default autoincr column. I really need to make additions to my column nroAux. Thanks!!

1 Answer 1

4

Aggregation actually returns a dictionary, and you can get the value same way as getting a value from dictionary using a key. For example (by using dict.get()):

maxAux = Auxi.objects.all().aggregate(max_val = Max('nroAux'))  # providing a key max_val

maxAux.get('max_val')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.