django SplitDateTimewidget deprecated - django

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?

Related

Use Non default database with ManyRelatedManager methods in django

I want to use a non default database with ManyRelatedManager's set method in django.
I have tried the following methods:
By mentioning the using method in the query
It gives me the following error:
AttributeError: 'QuerySet' object has no attribute 'set'
By using the db_manager with the relatedmanager like this: modelA.modelB_set.db_manager('new_db').set(modelB_list)
This doesn't give any error, but it uses the default database to do this.
Is there any way that I can use a non default database with set method of ManyRelatedManager? Thanks in advance.

Django 2.1 - 'WhereNode' object has no attribute 'output_field' error

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!

Django Create Custom Error Report

I want to modify the default Django error reporting template TECHNICAL_500_TEXT_TEMPLATE to provide custom error message. Read doc on modifying the filter tried
DEFAULT_EXCEPTION_REPORTER_FILTER = 'path.to.your.CustomExceptionReporterFilter' but it's about filtering data but I would like to override the default template itself.
Tried overriding DEFAULT_EXCEPTION_REPORTER_FILTER and defining custom get_traceback_text and hence passing custom template instead of TECHNICAL_500_TEXT_TEMPLATE in the method.
Any suggestions would be helpful
I started noticing the change in the emails after upgrading from 1.7 to 1.9. I used the approach in the following answer. I basically removed the 'settings' section from the templates, including a few other lines that weren't needed.
Django error email is too long. How do I truncate it?

'module' object has no attribute 'form_for_model'

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/

Cannot save property group to product in django-lfs

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