These are chat archives for django/django

21st
Jun 2018
:]
@elcolie
Jun 21 2018 05:18
@SanskarSans
https://github.com/elcolie/tryDj2/tree/master/studymptt
Check my modules carts and items
Since you are using M2M it does simplify nested serializer already. I haven't think about it since you show me your code. From now on I will use M2M for my Order/OrderItem because of you :D
I also add the TestCart to show you my payload in json. Hope I answer to your question
djangoReactGuy
@SanskarSans
Jun 21 2018 11:42
Thanks @elcolie . I will look into it. I think you should write the answer in SO as you have already done this for me so i can mark it as solved. Thanks again
Pete Tinkler
@ptink
Jun 21 2018 13:44
I have a data migration that I'm trying to create all my permissions etc in, using :
    for app_config in apps.get_app_configs():
        app_config.models_module = True
        create_permissions(app_config, verbosity=0)
        app_config.models_module = None
but for some reason, apps isn't an exhaustive list of all my apps? quite a few are missing and so the permissions don't get created
Pete Tinkler
@ptink
Jun 21 2018 14:13
I suspect it's an app loading issue.. i've found it easier to do app_config = apps.get_app_config("myapp") specifically in that apps migrations
so nevermind :)
Jahaziel Noriega
@jahazieldom
Jun 21 2018 19:05
Hello everyone, has someone managed to configure pgbouncer using django-tenants?
Diego Castro
@diegocastrum
Jun 21 2018 19:47

Hi everybody!

I need some idea to get something work. I want to create a form which contains a list of grouped checkboxes like:

group_one
  [] option_one
  [] option_two
group_two
  [] option_one
  [] options_three

Right now I've an intermediate table where I'm storing a option_id and a group_id.

I found this snippet but only works on Django 1.8, after that version some classes were removed from the core of the django forms...

I could to find the way to update the snippet, but I wonder if maybe somebody had the same situation and found a better solution to this challenge.

Thank you in advance!

Garrus Napp
@GarrusNapp
Jun 21 2018 21:27
Hello, how I can serialize an object with foreign key in django rest framework? I've got two models:
class CustomUser(AbstractUser):
    won = models.IntegerField(default=0)
    lost = models.IntegerField(default=0)
    won_by_surrender = models.IntegerField(default=0)
    draws = models.IntegerField(default=0)
    surrendered = models.IntegerField(default=0)

    def __str__(self):
        return self.username

class Game(models.Model):
    name = models.CharField(max_length=50)
    creator = models.ForeignKey('CustomUser', blank=True, related_name='games', on_delete=models.CASCADE)
    players_count = models.IntegerField(default=0)
    board = models.CharField(max_length=500)
    started = models.BooleanField(default=False)
    finished = models.BooleanField(default=False)
    surrendered = models.BooleanField(default=False)
    draw = models.BooleanField(default=False)

    def __str__(self):
        return "Game #" + str(self.id)
I'd like to return serialized Game so the creator in json is a nested serialized custom user