Django: inlineformset widgets throwing error - django

Hi I have a inlineformset form, i need to change css class of its fields. I am using widgets to change the class.
However I am get error.
My form:
createinvoiceformset = inlineformset_factory(serviceinvoice, serviceinvoiceitems,can_delete=True,form=invoiceitemsform,extra=2,widgets={'Quantity': FloatField(attrs={'class':'quantity'})})
Error:
TypeError at /invoice/createinvoice/
__init__() got an unexpected keyword argument 'attrs'
Request Method: GET
Request URL: http://localhost:8000/invoice/createinvoice/
Django Version: 1.8.9
Exception Type: TypeError
Exception Value:
__init__() got an unexpected keyword argument 'attrs'
Exception Location: C:\Python34\lib\site-packages\django\forms\fields.py in __init__, line 245
Python Executable: C:\Python34\python.exe
Python Version: 3.4.0
Python Path:
['D:\\pythonspace\\tiktant',
'C:\\Python34\\lib\\site-packages\\django_select2-4.3.2-py3.4.egg',
'C:\\Python34\\lib\\site-packages\\python_dateutil-2.2-py3.4.egg',
'C:\\Python34\\lib\\site-packages\\babel-1.3-py3.4.egg',
'C:\\Python34\\lib\\site-packages\\django_classy_tags-0.5.1-py3.4.egg',
'C:\\Python34\\lib\\site-packages\\django_datetime_widget-0.9.3-py3.4.egg',
'C:\\Python34\\lib\\site-packages\\django_select2_py3-4.2.1-py3.4.egg',
'C:\\Python34\\lib\\site-packages\\django_bootstrap3-4.11.0-py3.4.egg',
'C:\\Windows\\system32\\python34.zip',
'C:\\Python34\\DLLs',
'C:\\Python34\\lib',
'C:\\Python34',
'C:\\Python34\\lib\\site-packages']
Thank in advance for the help.

FloatField is not a widget. You should use NumberInput instead.

Related

Python 3.7 AttributeError: 'str' object has no attribute 'has'

Using Python 3.7.3 , PIP 19.3.1 , Django 2.2, I need to check whether an object is string or not and started by using this code:
if not isinstance(math, basestring):
math = latex(math)
return '<script type="math/tex; mode=display">{}</script>'.format(math)
Using 'str' instead of 'basestring' causes the script to output an error:
'str' object has no attribute 'get' error
I then tried the following code
def format_math_display(self, math):
try:
if not isinstance(math, basestring):
math = latex(math)
return '<script type="math/tex; mode=display">{}
</script>'.format(math)
except Exception:
pass
But it also leads to an(other) error:
AttributeError at /
'str' object has no attribute 'has'
Request Method: POST
Request URL: http://127.0.0.1:8000/
Django Version: 2.2.6
Exception Type: AttributeError
Exception Value: 'str' object has no attribute 'has'
Python Executable: C:\Users\Vasundhara\Envs\calculate\Scripts\python.exe
Python Version: 3.7.3
Python Path:
['C:\\wamp64\\www\\Python3Django2\\Calculate',
'C:\\Users\\Vasundhara\\Envs\\calculate\\Scripts\\python37.zip',
'C:\\Users\\Vasundhara\\Envs\\calculate\\DLLs',
'C:\\Users\\Vasundhara\\Envs\\calculate\\lib',
'C:\\Users\\Vasundhara\\Envs\\calculate\\Scripts',
'c:\\users\\vasundhara\\appdata\\local\\programs\\python\\python37\\Lib',
'c:\\users\\vasundhara\\appdata\\local\\programs\\python\\python37\\DLLs',
'C:\\Users\\Vasundhara\\Envs\\calculate',
'C:\\Users\\Vasundhara\\Envs\\calculate\\lib\\site-packages']
Server time: Sat, 26 Oct 2019 04:08:58 +0000
What am I missing here?

i have two projects in django i can not open admin site for my second project,but i can open for my first project,can any one help me

AttributeError at /admin/
'WSGIRequest' object has no attribute 'user'
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 2.0.2
Exception Type: AttributeError
Exception Value:
'WSGIRequest' object has no attribute 'user'
Exception Location: C:\Users\vaaz\Desktop\venv\lib\site-packages\django\contrib\admin\sites.py in has_permission, line 186
Python Executable: C:\Users\vaaz\Desktop\venv\Scripts\python.exe
Python Version: 3.4.3
Python Path:
['C:\Users\vaaz\website1',
'C:\Windows\system32\python34.zip',
'C:\Users\vaaz\Desktop\venv\DLLs',
'C:\Users\vaaz\Desktop\venv\lib',
'C:\Users\vaaz\Desktop\venv\Scripts',
'C:\Python34\Lib',
'C:\Python34\DLLs',
'C:\Users\vaaz\Desktop\venv',
'C:\Users\vaaz\Desktop\venv\lib\site-packages']
Server time: Mon, 12 Mar 2018 10:21:49 +0000
This looks similar to this post
with your limited error description I can only suggest a few things that were mentioned in the above post:
Older Django versions use MIDDLEWARE_CLASSES = (...) in the settings.py rather than MIDDLEWARE = (...) try changing that variable.
If you are using virtualenv be sure to activate it before trying to runserver
If you created your app in a different version of Django and then installed it on another version it might give you errors.

'WSGIRequest' object has no attribute 'id' - Django Oscar Paypal?

Trying to integrate Django-Oscar-Paypal with my project. I'm using Paypal express version. On checkout the flow is going to Paypal's site. But when the Paypal redirects back to my site I'm getting the following error.
AttributeError at /checkout/paypal/preview/16/
'WSGIRequest' object has no attribute 'id'
Request Method: GET
Request URL: http://localhost:8000/checkout/paypal/preview/16/?token=EC-9JB96808VX198132S&PayerID=TYNFGLXS46S2E
Django Version: 1.8.3
Exception Type: AttributeError
Exception Value:
'WSGIRequest' object has no attribute 'id'
Exception Location: /Users/nikhilsingh/djangoOscarEnv/lib/python2.7/site-packages/oscar/apps/offer/applicator.py in get_basket_offers, line 93
Python Executable: /Users/nikhilsingh/djangoOscarEnv/bin/python
Python Version: 2.7.6
Python Path:
['/Users/nikhilsingh/teabox_new/teashop',
'/Users/nikhilsingh/djangoOscarEnv/lib/python27.zip',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7/plat-darwin',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7/plat-mac',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/nikhilsingh/djangoOscarEnv/Extras/lib/python',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7/lib-tk',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7/lib-old',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/nikhilsingh/djangoOscarEnv/lib/python2.7/site-packages']
Server time: Mon, 5 Oct 2015 07:10:10 +0000
It seems like the basket gets empty on redirection hence no id is found. What can I do to resolve this issue ?

Django error xhtml2pdf

I am trying to generate a pdf with xhtml2pdf using a helper called django-xhtml2pdf but I am getting an error about the library xhtml2pdf. can you help me?
This is the error. thanks
SyntaxError at /
invalid syntax (util.py, line 302)
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.7.7
Exception Type: SyntaxError
Exception Value:
invalid syntax (util.py, line 302)
Exception Location: /usr/lib/python3.4/site-packages/xhtml2pdf/__init__.py in <module>, line 41
Python Executable: /usr/bin/python
Python Version: 3.4.3
Python Path:
['/home/ed/syscat',
'/usr/lib/python34.zip',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-linux',
'/usr/lib/python3.4/lib-dynload',
'/usr/lib/python3.4/site-packages']

django cms frontend editer display error

Am trying to access the django cmcs frontend editor and after input the login details, i get the following error.
AttributeError at /en/
'NoneType' object has no attribute 'has_change_permission'
Request Method: GET
Request URL: http://*.*.*.*:8000/en/
Django Version: 1.6.5
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'has_change_permission'
Exception Location: /home/bg/workspace/my-site/env/local/lib/python2.7/site-packages/cms/templatetags/cms_tags.py in get_processors, line 352
Python Executable: /home/bg/workspace/my-site/env/bin/python
Python Version: 2.7.3
Python Path:
['/home/bg/workspace/my-site',
'/home/bg/workspace/my-site/env/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg',
'/home/bg/workspace/my-site/env/lib/python2.7',
'/home/bg/workspace/my-site/env/lib/python2.7/plat-linux2',
'/home/bg/workspace/my-site/env/lib/python2.7/lib-tk',
'/home/bg/workspace/my-site/env/lib/python2.7/lib-old',
'/home/bg/workspace/my-site/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/bg/workspace/my-site/env/local/lib/python2.7/site-packages']
How can i fix it?
I faced a similar issue with django-cms 3.0.4 / Python 3.4, it may be related to the djangocms-column plugin (version 1.4).
This problem appeared when editing a page; either with djangocms-installer default pages, as well as when creating a new page at trying to add the multi-columns plugin into it.
For a bit more details, the error is encountered when interpreting {% render_plugin plugin %}, in multi_column.html (line #4):
In template /dvlpt/venv/my_project/lib/python3.4/site-packages/djangocms_column/templates/cms/plugins/multi_column.html, error at line 4
'NoneType' object has no attribute 'has_change_permission'
More exactly, the AttributeError exception is raised by line #352 of cms/templatetags/cms_tags.py, in get_processors():
if toolbar and toolbar.edit_mode and placeholder.has_change_permission(request) and getattr(placeholder, 'is_editable', True):
...
I've posted a comment at djangocms-colum github : https://github.com/divio/djangocms-column/issues/14
Sorry, I cannot bring a more useful help yet, as I'm very new to django-cms at this time...
Cheers