Django cannot unpack non-iterable 'Q' object Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!django - inlineformset_factory with more than one ForeignKeyShow information of subclass in list_display djangoDjango south migration error with unique field in postgresql databaseRadio buttons in django adminDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to expose some specific fields of model_b based on a field of model_a?Customer User Authentication error : AttributeError: Manager isn't available; 'auth.User' has been swapped for 'user_management.CustomUser'How to set dynamic initial values to django modelform fieldHow to define Mode with generic ForeignKey in DjangoDjango auto_now=True for Timestamp not working when using normal mysql update query

Can an iPhone 7 be made to function as a NFC Tag?

Relating to the President and obstruction, were Mueller's conclusions preordained?

Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?

I can't produce songs

Co-worker has annoying ringtone

Does silver oxide react with hydrogen sulfide?

How does light 'choose' between wave and particle behaviour?

RSA find public exponent

Trying to understand entropy as a novice in thermodynamics

Is multiple magic items in one inherently imbalanced?

Resize vertical bars (absolute-value symbols)

Would color changing eyes affect vision?

What does this say in Elvish?

Why are vacuum tubes still used in amateur radios?

Differences to CCompactSize and CVarInt

Positioning dot before text in math mode

retrieve food groups from food item list

Does any scripture mention that forms of God or Goddess are symbolic?

Tannaka duality for semisimple groups

One-one communication

Select every other edge (they share a common vertex)

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

Asymptotics question

What does 丫 mean? 丫是什么意思?



Django cannot unpack non-iterable 'Q' object



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!django - inlineformset_factory with more than one ForeignKeyShow information of subclass in list_display djangoDjango south migration error with unique field in postgresql databaseRadio buttons in django adminDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to expose some specific fields of model_b based on a field of model_a?Customer User Authentication error : AttributeError: Manager isn't available; 'auth.User' has been swapped for 'user_management.CustomUser'How to set dynamic initial values to django modelform fieldHow to define Mode with generic ForeignKey in DjangoDjango auto_now=True for Timestamp not working when using normal mysql update query



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















Im trying to use Q to make query in django. Database im using for this class is PostgreSQL.



My model is:



class DataSetPG(models.Model):
tower_code = models.CharField(max_length=20, null=False)
time_stamp = models.DateTimeField(default=datetime.now, null=True, blank=True)
value = models.CharField(max_length=200)

class Meta:
ordering = ('tower_code',)

def __str__(self):
return "%s" % self.tower_code


My view is asking for:



DataSetPG.objects.filter(Q(tower_code="something"))


But i got this error:



TypeError: cannot unpack non-iterable Q object


What I'm doing wrong? I tried .get instead of .filter and many many other kinds of stuff, but nothing. Im also using Q for querying in mongo database and works fine.










share|improve this question






















  • Just some more info. Using the normal query works: DataSetPG.objects.filter(tower_code="port525")

    – Pedro Faria
    Mar 8 at 22:53











  • Just in case, what class are you importing for Q?

    – 17slim
    Mar 8 at 23:02











  • @17slim yes thats the problem, im importing: mongoengine.queryset.visitor How can i use two Q' from different classes?

    – Pedro Faria
    Mar 8 at 23:15











  • from mongoengine.queryset.visitor import Q as MongoQ and from django.db.models import Q as DjangoQ

    – 17slim
    Mar 8 at 23:32

















1















Im trying to use Q to make query in django. Database im using for this class is PostgreSQL.



My model is:



class DataSetPG(models.Model):
tower_code = models.CharField(max_length=20, null=False)
time_stamp = models.DateTimeField(default=datetime.now, null=True, blank=True)
value = models.CharField(max_length=200)

class Meta:
ordering = ('tower_code',)

def __str__(self):
return "%s" % self.tower_code


My view is asking for:



DataSetPG.objects.filter(Q(tower_code="something"))


But i got this error:



TypeError: cannot unpack non-iterable Q object


What I'm doing wrong? I tried .get instead of .filter and many many other kinds of stuff, but nothing. Im also using Q for querying in mongo database and works fine.










share|improve this question






















  • Just some more info. Using the normal query works: DataSetPG.objects.filter(tower_code="port525")

    – Pedro Faria
    Mar 8 at 22:53











  • Just in case, what class are you importing for Q?

    – 17slim
    Mar 8 at 23:02











  • @17slim yes thats the problem, im importing: mongoengine.queryset.visitor How can i use two Q' from different classes?

    – Pedro Faria
    Mar 8 at 23:15











  • from mongoengine.queryset.visitor import Q as MongoQ and from django.db.models import Q as DjangoQ

    – 17slim
    Mar 8 at 23:32













1












1








1








Im trying to use Q to make query in django. Database im using for this class is PostgreSQL.



My model is:



class DataSetPG(models.Model):
tower_code = models.CharField(max_length=20, null=False)
time_stamp = models.DateTimeField(default=datetime.now, null=True, blank=True)
value = models.CharField(max_length=200)

class Meta:
ordering = ('tower_code',)

def __str__(self):
return "%s" % self.tower_code


My view is asking for:



DataSetPG.objects.filter(Q(tower_code="something"))


But i got this error:



TypeError: cannot unpack non-iterable Q object


What I'm doing wrong? I tried .get instead of .filter and many many other kinds of stuff, but nothing. Im also using Q for querying in mongo database and works fine.










share|improve this question














Im trying to use Q to make query in django. Database im using for this class is PostgreSQL.



My model is:



class DataSetPG(models.Model):
tower_code = models.CharField(max_length=20, null=False)
time_stamp = models.DateTimeField(default=datetime.now, null=True, blank=True)
value = models.CharField(max_length=200)

class Meta:
ordering = ('tower_code',)

def __str__(self):
return "%s" % self.tower_code


My view is asking for:



DataSetPG.objects.filter(Q(tower_code="something"))


But i got this error:



TypeError: cannot unpack non-iterable Q object


What I'm doing wrong? I tried .get instead of .filter and many many other kinds of stuff, but nothing. Im also using Q for querying in mongo database and works fine.







django






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 22:47









Pedro FariaPedro Faria

153




153












  • Just some more info. Using the normal query works: DataSetPG.objects.filter(tower_code="port525")

    – Pedro Faria
    Mar 8 at 22:53











  • Just in case, what class are you importing for Q?

    – 17slim
    Mar 8 at 23:02











  • @17slim yes thats the problem, im importing: mongoengine.queryset.visitor How can i use two Q' from different classes?

    – Pedro Faria
    Mar 8 at 23:15











  • from mongoengine.queryset.visitor import Q as MongoQ and from django.db.models import Q as DjangoQ

    – 17slim
    Mar 8 at 23:32

















  • Just some more info. Using the normal query works: DataSetPG.objects.filter(tower_code="port525")

    – Pedro Faria
    Mar 8 at 22:53











  • Just in case, what class are you importing for Q?

    – 17slim
    Mar 8 at 23:02











  • @17slim yes thats the problem, im importing: mongoengine.queryset.visitor How can i use two Q' from different classes?

    – Pedro Faria
    Mar 8 at 23:15











  • from mongoengine.queryset.visitor import Q as MongoQ and from django.db.models import Q as DjangoQ

    – 17slim
    Mar 8 at 23:32
















Just some more info. Using the normal query works: DataSetPG.objects.filter(tower_code="port525")

– Pedro Faria
Mar 8 at 22:53





Just some more info. Using the normal query works: DataSetPG.objects.filter(tower_code="port525")

– Pedro Faria
Mar 8 at 22:53













Just in case, what class are you importing for Q?

– 17slim
Mar 8 at 23:02





Just in case, what class are you importing for Q?

– 17slim
Mar 8 at 23:02













@17slim yes thats the problem, im importing: mongoengine.queryset.visitor How can i use two Q' from different classes?

– Pedro Faria
Mar 8 at 23:15





@17slim yes thats the problem, im importing: mongoengine.queryset.visitor How can i use two Q' from different classes?

– Pedro Faria
Mar 8 at 23:15













from mongoengine.queryset.visitor import Q as MongoQ and from django.db.models import Q as DjangoQ

– 17slim
Mar 8 at 23:32





from mongoengine.queryset.visitor import Q as MongoQ and from django.db.models import Q as DjangoQ

– 17slim
Mar 8 at 23:32












1 Answer
1






active

oldest

votes


















0














Putting my comment as an answer:



You can't use the Mongo Q as a Django Q to my understanding. You should instead import like so:



from mongoengine.queryset.visitor import Q as MongoQ
from django.db.models import Q as DjangoQ


With this, instead of Q(tower_code='something') use DjangoQ(tower_code='something'). Wherever you used the Q from mongoengine, replace it with MongoQ.






share|improve this answer























  • Yes, that's it. I was already desperate with this and didn't pay attention to the import. Thank you.

    – Pedro Faria
    Mar 9 at 0:27











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072051%2fdjango-cannot-unpack-non-iterable-q-object%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Putting my comment as an answer:



You can't use the Mongo Q as a Django Q to my understanding. You should instead import like so:



from mongoengine.queryset.visitor import Q as MongoQ
from django.db.models import Q as DjangoQ


With this, instead of Q(tower_code='something') use DjangoQ(tower_code='something'). Wherever you used the Q from mongoengine, replace it with MongoQ.






share|improve this answer























  • Yes, that's it. I was already desperate with this and didn't pay attention to the import. Thank you.

    – Pedro Faria
    Mar 9 at 0:27















0














Putting my comment as an answer:



You can't use the Mongo Q as a Django Q to my understanding. You should instead import like so:



from mongoengine.queryset.visitor import Q as MongoQ
from django.db.models import Q as DjangoQ


With this, instead of Q(tower_code='something') use DjangoQ(tower_code='something'). Wherever you used the Q from mongoengine, replace it with MongoQ.






share|improve this answer























  • Yes, that's it. I was already desperate with this and didn't pay attention to the import. Thank you.

    – Pedro Faria
    Mar 9 at 0:27













0












0








0







Putting my comment as an answer:



You can't use the Mongo Q as a Django Q to my understanding. You should instead import like so:



from mongoengine.queryset.visitor import Q as MongoQ
from django.db.models import Q as DjangoQ


With this, instead of Q(tower_code='something') use DjangoQ(tower_code='something'). Wherever you used the Q from mongoengine, replace it with MongoQ.






share|improve this answer













Putting my comment as an answer:



You can't use the Mongo Q as a Django Q to my understanding. You should instead import like so:



from mongoengine.queryset.visitor import Q as MongoQ
from django.db.models import Q as DjangoQ


With this, instead of Q(tower_code='something') use DjangoQ(tower_code='something'). Wherever you used the Q from mongoengine, replace it with MongoQ.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 8 at 23:34









17slim17slim

86411220




86411220












  • Yes, that's it. I was already desperate with this and didn't pay attention to the import. Thank you.

    – Pedro Faria
    Mar 9 at 0:27

















  • Yes, that's it. I was already desperate with this and didn't pay attention to the import. Thank you.

    – Pedro Faria
    Mar 9 at 0:27
















Yes, that's it. I was already desperate with this and didn't pay attention to the import. Thank you.

– Pedro Faria
Mar 9 at 0:27





Yes, that's it. I was already desperate with this and didn't pay attention to the import. Thank you.

– Pedro Faria
Mar 9 at 0:27



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072051%2fdjango-cannot-unpack-non-iterable-q-object%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович