OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

django_get_or_create doesn't let me create instances

  • Thread starter Thread starter Paul Allen
  • Start date Start date
P

Paul Allen

Guest
I'm using ModelFactory through SubFactory and there was django_get_or_create Meta field with ('code') inside. I put my 2 new added to model fields to this field django_get_or_create and it literally stopped making countries with 'RU' code and didint fill my array? There's an issue with this field or im doing something really wrong?

I did try to search for similar problem but didn't find anything [

Code:
class ModelFactory(DjangoModelFactory):
    code = "RU"
    predefined_amounts_one_time = [500, 1000, 3000]
    predefined_amounts_recurring = [500, 1000, 3000]

    class Meta:
        model = Model
        django_get_or_create = ("predefined_amounts_one_time", "predefined_amounts_recurring", "code")]

1

this is what i get multiple times in tests when i try to print those fields: Turkey []

Turkey is an aliase to TR
<p>I'm using ModelFactory through SubFactory and there was django_get_or_create Meta field with ('code') inside. I put my 2 new added to model fields to this field django_get_or_create and it literally stopped making countries with 'RU' code and didint fill my array? There's an issue with this field or im doing something really wrong?</p>
<p>I did try to search for similar problem but didn't find anything
[</p>
<pre><code>class ModelFactory(DjangoModelFactory):
code = "RU"
predefined_amounts_one_time = [500, 1000, 3000]
predefined_amounts_recurring = [500, 1000, 3000]

class Meta:
model = Model
django_get_or_create = ("predefined_amounts_one_time", "predefined_amounts_recurring", "code")]
</code></pre>
<p><a href="https://i.sstatic.net/F0k48iRV.png" rel="nofollow noreferrer">1</a></p>
<p>this is what i get multiple times in tests when i try to print those fields:
Turkey
[]</p>
<p>Turkey is an aliase to TR</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top