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;
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
add a comment |
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
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 MongoQandfrom django.db.models import Q as DjangoQ
– 17slim
Mar 8 at 23:32
add a comment |
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
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
django
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 MongoQandfrom django.db.models import Q as DjangoQ
– 17slim
Mar 8 at 23:32
add a comment |
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 MongoQandfrom 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
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 MongoQandfrom django.db.models import Q as DjangoQ– 17slim
Mar 8 at 23:32