Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

330
Views
int() argument must be a string, a bytes-like object or a number, not 'generator' django

I have the following error how can I solve it?

the model is:

 class myModel(models.Model): name = models.CharField(max_length=50) libraries = models.ManyToManyField(library)

and on the endpoint like this:

 new_obj = myModel.objects.create(name=name) my_obj.libraries.add(Library.objects.filter(pk=l.pk) for l in input_libraries.get('libraries'))

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are trying to save a generator in an add which is to add a single element.

A generator object in python is something like a lazy list. Elements are only evaluated as soon as you iterate over them.

so to solve it use set()

 my_obj.libraries.set(Library.objects.filter(pk=l.pk) for l in input_libraries.get('libraries'))
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!