These are chat archives for django/django

4th
Feb 2019
sahil-developer-88
@sahil-developer-88
Feb 04 04:40

Hi,
I already installed packages, but python is still giving me error message regarding not installed packages something :
eg.:-

import requests
ModuleNotFoundError: No module named 'requests'

Can anyone please help me to resolve this issue?

Mohammad Zaman
@mzaman07
Feb 04 07:13
@sahil-developer-88 is this about incoming HTTP requests?
sahil-developer-88
@sahil-developer-88
Feb 04 07:19
@mzaman07 the issue was resolved, i went into python.exe folder and installed packages there, then i run my project, so, the modules giving notfounderror error got resolved now.
Mohammad Zaman
@mzaman07
Feb 04 07:20
ok I see
that's good
sahil-developer-88
@sahil-developer-88
Feb 04 07:22
@mzaman07 thanks for your support
Luke-VideoLibre
@LukeVideo
Feb 04 11:26

Hy All, I'm using django with Django graphene to provide a graphQl server to my frontend witch is a create-react-app with apollo.and apollo-link-state Everything is good and nice until ....
Aparently the type defenintion isn't compatible with / can't handle a many to many through object.
Has anyone advise, had this issue ?
Here is my case

class Question(models.Model):
    name = models.CharField(max_length=50, default="Default_name")
    text = models.CharField(max_length=50, default="Question text ...")

    def __str__(self):
        return self.name

class Formo(models.Model):
    name = models.CharField(max_length=50)
    entity = models.ForeignKey(Entity, on_delete=models.CASCADE)
    question_set = models.ManyToManyField('Question', through='FormoQuestion')

    def __str__(self):
        return self.name

class FormoQuestion(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    formo = models.ForeignKey(Formo, on_delete=models.CASCADE)

    number = models.PositiveIntegerField()

    def __str__(self):
        return '%s_%s_%i' % (self.formo, self.question, self.number)
    class Meta:
        ordering = ('number',)

So i can't get The QuestionSet to work this way.
Is it possible to handle many to many fields differently ?