I am trying to filter some annotations in a ViewSetlike so:
queryset = Confirmation.objects.values('prediction__specimen_id').annotate(
sample_id=F('target_prediction__specimen_id'),
num_selected=Count('selected', filter=Q(selected=True)),
num_validated=Count('validated', filter=Q(validated=True)),
num_has_standard=Count('has_standard', filter=Q(has_standard=True)))
However, I am getting the following error:
'WhereNode' object has no attribute 'output_field'
My syntax seems to be correct according to all guides. I am running Django 2.1. Any idea what's happening? Can I not do this in Django Rest Framework because of paging?
Looks like syntax was indeed the issue. My answer has been edited to include the correct code. Cheers!
Related
screenshotI'm following a tutorial to create a website using django. I keep getting this error when running the server.
path('page2',index.webpage2),
AttributeError: module 'website.index' has no attribute 'webpage2'. Did you mean: 'webpage1'?
Don't know what I'm missing, the tutorial ran the server without any problem. The only thing I noticed was that it also gave my a missing os error. I fixed this part.
Thank you for your help
You need to add two views correspoending to the url
def webpage2(request):
pass
def webpage3(request):
pass
I have a django project that uses google maps. I wanted to create a GIS application using GeoDjango and Google Maps following this tutorial but went through several issues.
Now I'm stuck, although I decided to remove everything but django still throwing this error regardless I removed all the details related to GIS:
AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'
I mean there is nothing at all that relate my django project (in the code) to GIS?!
I feel like installing GIS/postgres must have messed up the django default database system.
Any suggestions?
I think I will solve this problem by myself. I found two similar questions here in this place and no one solved them or gave a clear answer.
See this:
GeoDjango error: 'DatabaseOperations' object has no attribute 'geo_db_type'
Which means no clear solution and gotta get around it myself.
This post is thus closed.
I'm using widgets.AdminSplitDateTime in a create view that is corresponding to a datetime field.
When I try to create the object it gives me the following error:
RemovedInDjango19Warning: Using SplitDateTimeWidget with DateTimeField is deprecated. Use SplitDateTimeField instead.
I have searched the web for an answer about how to use it but I couldn't find anything that works..
I tries to change the widgets.AdminSplitDateTime to forms.SplitDateTimeField and it gave me the following error:
'SplitDateTimeField' object has no attribute 'is_hidden'
can someone help me on figuring out how to use it?
When I am using attribute
form_for_model
I am getting an error module object has not attribute form_for_model..
I created the project from this http://www.mikecantelon.com/?q=node/22
but I am getting the above can any body help me
The post you are referring to is fairly old (2007) and a few things have changed since then:
form_for_model is deprecated.
I'd say you are better off looking at the official tutorial to get started with django.
The current way for creating forms based on models is explained in this part of the docs:
http://docs.djangoproject.com/en/1.8/topics/forms/modelforms/
I already create properties and add them to property group.Then I assign to my new product.But django show me
TypeError at /manage/update-product-properties/1
save() got an unexpected keyword argument 'using'
Yeah, as you point out in your comment to your OP, the problem went away by using a different version of Django. using is part of the machinery for multi-database support in Django 1.2