TypeError at / 'set' object is not reversible - django-views

Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 4.1.3
Exception Type: TypeError
Exception Value:
'set' object is not reversible
Exception Location: D:\Django\Django tamrin\porfoliaproject\Venv\Lib\site-packages\django\urls\resolvers.py, line 543, in _populate
Raised during: work.views.portfolio_view
Python Executable: D:\Django\Django tamrin\porfoliaproject\Venv\Scripts\python.exe
Python Version: 3.11.0
Python Path:
['D:\Django\Django tamrin\porfoliaproject\MyPortfolio',
'C:\Users\Platin-PC\AppData\Local\Programs\Python\Python311\python311.zip',
'C:\Users\Platin-PC\AppData\Local\Programs\Python\Python311\DLLs',
'C:\Users\Platin-PC\AppData\Local\Programs\Python\Python311\Lib',
'C:\Users\Platin-PC\AppData\Local\Programs\Python\Python311',
'D:\Django\Django tamrin\porfoliaproject\Venv',
'D:\Django\Django tamrin\porfoliaproject\Venv\Lib\site-packages']
Server time: Thu, 17 Nov 2022 10:37:43 +0000
to display work details

Related

Not able to save data in Database using for loop

my proposal:
I want add network IP range with prefix in web UI and need to process using command
ipaddress.IPv4Network(subnet).hosts())
then after IP range will crate and save all range of IP into DATABASE.
I have tried deferent methods still not able to complete my requirement.
some one could help about.
below the code which I made.
def Indexping(request):
form = IpModelForm
Ipform = {'form':form}
if request.method=='POST':
subnet = IpModelForm(request.POST)
if subnet.is_valid:
data= list(ipaddress.IPv4Network(subnet).hosts())
for f in data:
#f = [x for x in subnet]
f.save()
Exception Value:
Only one '/' permitted in
Getting Below Error:
AddressValueError at /cbv/ind/
Only one '/' permitted in
Request Method: POST
Request URL: http://127.0.0.1:8000/cbv/ind/
Django Version: 4.0.2
Exception Type: AddressValueError
Exception Value:
Only one '/' permitted in
Exception Location: D:\Program Files\Python\Python39\lib\ipaddress.py, line 162, in _split_optional_netmask
Python Executable: E:\Django_Projects\Portal-env\Scripts\python.exe
Python Version: 3.9.10
Python Path:
['E:\Django_Projects\Portal-env\portal',
'D:\Program Files\Python\Python39\python39.zip',
'D:\Program Files\Python\Python39\DLLs',
'D:\Program Files\Python\Python39\lib',
'D:\Program Files\Python\Python39',
'E:\Django_Projects\Portal-env',
'E:\Django_Projects\Portal-env\lib\site-packages']
Server time: Sat, 19 Feb 2022 09:35:57 +0000

get() returned more than one -- it returned 2

Error:
MultipleObjectsReturned at /fill/3e730d3858fbca620b1376f72e06473b227e5658/
get() returned more than one survey_participant -- it returned 2!
Request Method: GET
Request URL: *secret url cant share*
Django Version: 1.8.4
Exception Type: MultipleObjectsReturned
Exception Value:
get() returned more than one survey_participant -- it returned 2!
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/models/query.py in get, line
338
Python Executable: /usr/local/bin/uwsgi
Python Version: 2.7.3
Python Path:
['.',
'',
'/usr/local/lib/python2.7/dist-packages/distribute-0.7.3-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/pymodules/python2.7']
Server time: Sat, 6 Feb 2021 23:47:07 +0530
survey/views.py: This is where the error is occurring, in line get_or_none. I'm getting two objects here.
def fill(request, link):
fp = get_or_none(survey_participant, link__exact=link)
if not fp:
return render(request, 'survey/fill.html',
{'errormessage': constants.SURVEY_LINK_INVALID_TEXT})
What should I do now?

attempt to write a readonly database

Request Method: POST
Request URL: http://localhost:8000/users/
Django Version: 3.0.3
Exception Type: OperationalError
Exception Value:
**attempt to write a readonly database**
Exception Location: C:\Users\parul\anaconda\envs\MyDjangoEnv\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 396
Python Executable: C:\Users\parul\anaconda\envs\MyDjangoEnv\python.exe
Python Version: 3.8.5
Python Path:
['C:\\Users\\parul\\Desktop\\Djangoforms\\ProTwo',
'C:\\Users\\parul\\anaconda\\envs\\MyDjangoEnv\\python38.zip',
'C:\\Users\\parul\\anaconda\\envs\\MyDjangoEnv\\DLLs',
'C:\\Users\\parul\\anaconda\\envs\\MyDjangoEnv\\lib',
'C:\\Users\\parul\\anaconda\\envs\\MyDjangoEnv',
'C:\\Users\\parul\\anaconda\\envs\\MyDjangoEnv\\lib\\site-packages']
Server time: Wed, 23 Dec 2020 16:14:46 +0000
Also, i checked the properties in db.sqlite3, all the permissions are checked...write permission also
can anyone help
using windows... i tried : cacls . /t /e /g everyone:f
but still facing the same issue
Make permissions for the folder that contains the Database will solve the problem.
Also, you can run it as administrator to solve problem.

django & send_mail in docker leads to SMTPServerDisconnected

I setup a google email backend for django and all is working fine until i run the whole stuff in docker-compose containers.
SMTPServerDisconnected at /events/register/4/
please run connect() first
Request Method: GET
Request URL: http://192.168.99.100:80/events/register/4/
Django Version: 1.11.3
Exception Type: SMTPServerDisconnected
Exception Value:
please run connect() first
Exception Location: /usr/local/lib/python3.6/smtplib.py in send, line 359
Python Executable: /usr/local/bin/uwsgi
Python Version: 3.6.2
Python Path:
['.',
'',
'/usr/local/lib/python36.zip',
'/usr/local/lib/python3.6',
'/usr/local/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/site-packages',
'/app']
Server time: Tue, 25 Jul 2017 11:07:45 +0200
Any idea what's going wrong here? Why is it disconnecting in a container?
Just figured it out:
In the docker-compose.yml i have something like this:
env_file:
- ".env"
The content of the .env was:
key = value
This runs great on a local machine loading the .env file first.
However docker needs a more strict format:
key=value
No spaces!!
The error was that my EMAIL_* settings wasn't set correctly with spaced key/value pairs

serving static files from heroku

I have created a simple portfolio website on manojmj.herokuapp.com
I want to host the images,css etc on heroku itself and does not want to move to s3 since its only 800kb in size.
My site is running fine and displaying the images correctly on my local dev server(127.0.0.1:8000)
However, on manojmj.herokuapp.com I can see only the markup and no images.
When I click the image url I get the errror:
ValueError at /static/images/me.jpg
dictionary update sequence element #0 has length 35; 2 is required
Request Method: GET
Request URL: http://www.manojmj.com/static/images/me.jpg
Django Version: 1.4.3
Exception Type: ValueError
Exception Value:
dictionary update sequence element #0 has length 35; 2 is required
Exception Location: /app/.heroku/python/lib/python2.7/site- packages/django/core/urlresolvers.py in resolve, line 207
Python Executable: /app/.heroku/python/bin/python
Python Version: 2.7.4
Python Path:
['/app',
'/app/.heroku/python/bin',
'/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg',
'/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time: Fri, 21 Jun 2013 09:37:01 -0500
my urls.py
url(r'^static/(?P<path>.*)$','django.views.static.serve',{'document_root: settings.STATIC_ROOT'}),
url(r'^static/css/(?P<path>.*)$','django.views.static.serve',{'document_root: settings.STATIC_ROOT'}),
url(r'^static/images/(?P<path>.*)$','django.views.static.serve','document_root: settings.STATIC_ROOT'),
url(r'^static/js/(?P<path>.*)$','django.views.static.serve',{'document_root: settings.STATIC_ROOT'}),
url(r'^hello/', 'manojmjapp.views.hello'),
url(r'^$', 'manojmjapp.views.home'),
try to change this line :
url(r'^static/images/(?P<path>.*)$','django.views.static.serve','document_root: settings.STATIC_ROOT'),
for this:
url(r'^static/images/(?P<path>.*)$','django.views.static.serve',{'document_root': 'settings.STATIC_ROOT'}),