Giter Club home page Giter Club logo

django-3-by-example's Introduction

Django 3 by Example

This is the code repository for Django 3 by Example, written by Antonio Melé and published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

⚠️ New edition available

Check out the source code for the latest edition of this book: Django 4 by Example

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781838981952

django-3-by-example's People

Contributors

joshuamjv2 avatar kishorrit avatar packt-itservice avatar packtutkarshr avatar zenx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-3-by-example's Issues

Chapter 5: image saving time

Hi everybody,

I'm not sure whether this is normal or whether I messed something up: I select an image from the bookmarklet, the "bookmark an image" page opens, I click on "bookmark it", and it takes roughly a minute until the image_detail view opens. There are no error messages, and I see only return codes 200 and 302 in the server console.

Any idea what could be going wrong, or how to find out what the error is?

Thanks,
jrdjango

Chapter 9: django-parler version

Hi
thanks for this amazing book.

while following along, I found that django-parler==2.0.1 has some problem

  1. from django.forms.forms import BoundField
  2. django.forms.forms import pretty_name

both of these are incorrect reference. those should be

  1. from django.forms import BoundField
  2. django.forms.utils import pretty_name

but django-parler==2.2 has fixed it.
So I think, using this version will be proper
Thanks

createdb: could not connect to database template1: FATAL: Peer authentication failed for user "blog"

When i run

sudo bash
su postgres 
createuser -dP blog
createdb -E utf8 -U blog blog

get error createdb: could not connect to database template1: FATAL: Peer authentication failed for user "blog"

the following command fix the problem

createdb -E utf8 -U blog -h 127.0.0.1 blog

and the database setting become

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'blog',
        'USER':'blog',
        'PASSWORD':'123456',
        'HOST':'127.0.0.1'
    }
}

django.db.utils.OperationalError when migrating new postgresql base

i run:

python manage.py migrate

on Windows 10, postgresql12 and get this error

Traceback (most recent call last):
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
self.connect()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\base\base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\postgresql\base.py", line 185, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\Splendor\Envs\World\lib\site-packages\psycopg2_init_.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "manage.py", line 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\core\management_init_.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\core\management_init_.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\core\management\commands\migrate.py", line 86, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\migrations\executor.py", line 18, in init
self.loader = MigrationLoader(self.connection)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\migrations\loader.py", line 49, in init
self.build_graph()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\migrations\loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\migrations\recorder.py", line 76, in applied_migrations
if self.has_table():
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\base\base.py", line 260, in cursor
return self._cursor()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\base\base.py", line 236, in cursor
self.ensure_connection()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
self.connect()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\base\base.py", line 220, in ensure_connection
self.connect()
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\base\base.py", line 197, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\Splendor\Envs\World\lib\site-packages\django\db\backends\postgresql\base.py", line 185, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\Splendor\Envs\World\lib\site-packages\psycopg2_init
.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError

Chapter 6: Not Found: /account/users/follow/

hi.
I've done Building a follow system and run the server and try following a user but it gets me this error:

Not Found: /account/users/follow/
[26/May/2020 17:24:58] "POST /account/users/follow/ HTTP/1.1" 404 1757

I copied domready block, url path and views.user_follow from github but have problem yet

Secure connection not working chapter 4

After following the instructions by installing the third-party packages, and also added the cert file to my Trusted root certificates, I still don't have a secure connection

pagination chapter 1

hello,I have one problem
when I use class base view , It can't render page object. and in my template it goes like this:
Page of .
It doesn't work..
I checked my view It was the same with the book.

Chapter 4 base.html

In my base.html the {% if section... class='selected' i the li tags has no effect and the item doesn't get highlighted. However, it seems that my editor has an issue with the logic being placed inside of li particularly each of the == has different syntax highlighting. I changed quotes to single to see if that made a difference and I copied the code in the source code and again, no difference.
image

Email does not get send from chapter 8

I have implemented the settings email etc. And the task for sending email. It is visible in the celery console. but I don't see the email in my real inbox. Out outbox from the sending email. Have down the google security softener and get in console:[2020-09-12 06:57:01,691: INFO/ForkPoolWorker-16] Task payment.tasks.payment_completed[8176d113-a447-4bf4-b7f4-ea0cf1d4d3c4] succeeded in 0.2296765129999585s: None

What do I miss in sending the email? So it arrives in my inbox with the pdf?

markdown ch:3

links doesn't work in markdown. Text renders normally with no problem only anchors does not work. I think it's a chrome based web browser issue or maybe a security fix.
Has anybody encountered the same issue?

chapter 13 Chat does not respond in chat box

in chapter 13 I implement the chatbox. The chat box does work in the console. But does not show code in chat screen in frontend. Cloned the example and did the installment of packages. There the chat box doesn't seem to work either. How to fix this? in cloned code and the project?

[C3,P90] Trigram Similarity seems to be not working!

Well, I understood the type of search although it seems to be not working.
I tried to execute the command: CREATE EXTENSION pg_trgm;, but the database responded the extension already exists.
error
A piece of code I typed should be correct. I hope so.

If the word typed correctly - the engine won't find it. If the word is long enough as 'everything' - the engine will find it. Nonetheless if it contains a typo - the search won't find it.

It more or less works as a simple search function. I wonder why....

Ecommerce project

error report
I am currently working on the ecommerce application and i'm stuck with the error below. I have been googling for the past 3 days looking for a solution all to no avail...👇🏿👇🏿👇🏿. The initial error i was having need i install GTk and after i successfully doing that then i began have this new error and its been driving me crazy.. would really appreciate the urgent help as i am working on a deadline..

OSError: cannot load library 'gobject-2.0': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0'

Thanks

Chapter 3

I was trying to add the RSS feed to my blog.
The error message indicates PATH-to-my-Project/lib/python3.8/site-packages/django/db/models/query.py in get, line 415

Request Method: GET
http://127.0.0.1:8000/blog/feed/
3.0.10
DoesNotExist
Site matching query does not exist.

I tried to add path to the blog url.y and it did not work.
Is there anything we have to add to models , setting or view?

Empty Cart - An Online Shop

Viewing an empty cart gives this error:
redis.exceptions.ResponseError: wrong number of arguments for 'zunionstore' command
how and where can I fix this?
Thanks.

Getting a response error for zunionstore

ResponseError at /en/cart/
wrong number of arguments for 'zunionstore' command

recommended_products = r.suggest_products_for(cart_products, max_results=4) 
r.zunionstore(tmp_key, keys) 

When a product is added to the cart its fine, but when there are no products in the cart or when we remove all the products from the cart it throws this error

Using Celery on Windows

pg267

OS: Windows 10

When running celery from the shell using the provided command...
celery -A myshop worker -l info

the shell will fail once an order is placed.

ValueError: not enough values to unpack (expected 3, got 0)

According to StackOverflow, Celery 4+ is not fully supported on Windows. However, there was a solution.

pip install gevent
celery -A myshop worker -l info -P gevent

Performing AJAX queries with jQuery

I have 2 issues :
If I split the template tag onto 2 lines then the endwith tag is seen as an error and the with tag is not recognised.
image

Then next issue is when clicking on the like button on the image detail nothing happens; has anyone experienced the same? Are they related?

EDIT
This is what i see in the network tab of the console
image

so I will probably find the problem soon and will update.

Thanks in advance

  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 469, in parse
    compile_func = self.tags[command]
KeyError: 'endwith'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return self.application(environ, start_response)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
    response = self.get_response(request)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/base.py", line 75, in get_response
    response = self._middleware_chain(request)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django_extensions/management/technical_response.py", line 37, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/sueholder/Desktop/code/bookmarks/src/images/views.py", line 36, in image_detail
    return render(request,
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/loader.py", line 15, in get_template
    return engine.get_template(template_name)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/backends/django.py", line 34, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/engine.py", line 143, in get_template
    template, origin = self.find_template(template_name)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/engine.py", line 125, in find_template
    template = loader.get_template(name, skip=skip)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/loaders/base.py", line 29, in get_template
    return Template(
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 156, in __init__
    self.nodelist = self.compile_nodelist()
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 194, in compile_nodelist
    return parser.parse()
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 477, in parse
    raise self.error(token, e)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 475, in parse
    compiled_result = compile_func(self, token)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/loader_tags.py", line 266, in do_extends
    nodelist = parser.parse()
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 477, in parse
    raise self.error(token, e)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 475, in parse
    compiled_result = compile_func(self, token)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/loader_tags.py", line 209, in do_block
    nodelist = parser.parse(('endblock',))
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 471, in parse
    self.invalid_block_tag(token, command, parse_until)
  File "/Users/sueholder/.local/share/virtualenvs/bookmarks-4AItjxlP/lib/python3.8/site-packages/django/template/base.py", line 521, in invalid_block_tag
    raise self.error(
django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 40: 'endwith', expected 'endblock'. Did you forget to register or load this tag?```

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)>

Chapter 5: Added a description and click on the BOOKMARK IT! button.
I am stuck here

urllib.error.URLError

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)>

Traceback (most recent call last)

  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  h.request(req.get_method(), req.selector, req.data, headers,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  encode_chunked=req.has_header('Transfer-encoding'))
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except OSError as err: # timeout error
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise URLError(err)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  r = h.getresponse()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  h.close()
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._send_output(message_body, encode_chunked=encode_chunked)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def request(self, method, url, body=None, headers={}, *,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  encode_chunked=False):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """Send a complete request to the server."""
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._send_request(method, url, body, headers, encode_chunked)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def _send_request(self, method, url, body, headers, encode_chunked):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # Honor explicitly requested Host: and Accept-Encoding: headers.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  header_names = frozenset(k.lower() for k in headers)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  skips = {}
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.putheader(hdr, value)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if isinstance(body, str):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # RFC 2616 Section 3.7.1 says that text default has a
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # default charset of iso-8859-1.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  body = _encode(body, 'body')
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.endheaders(body, encode_chunked=encode_chunked)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def getresponse(self):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """Get the response from the server.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  If the HTTPConnection is in the correct state, returns an
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if self.__state == _CS_REQ_STARTED:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.__state = _CS_REQ_SENT
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  else:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise CannotSendHeader()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._send_output(message_body, encode_chunked=encode_chunked)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def request(self, method, url, body=None, headers={}, *,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  encode_chunked=False):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """Send a complete request to the server."""
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._send_request(method, url, body, headers, encode_chunked)
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  A message_body may be specified, to be appended to the request.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._buffer.extend((b"", b""))
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  msg = b"\r\n".join(self._buffer)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  del self._buffer[:]
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.send(msg)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if message_body is not None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # create a consistent interface to message_body
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if hasattr(message_body, 'read'):
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  file-like object that supports a .read() method, or an iterable object.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if self.sock is None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if self.auto_open:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.connect()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  else:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise NotConnected()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if self.debuglevel > 0:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  print("send:", repr(data))
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  server_hostname = self._tunnel_host
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  else:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  server_hostname = self.host
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.sock = self._context.wrap_socket(self.sock,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  server_hostname=server_hostname)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if not self._context.check_hostname and self._check_hostname:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  ssl.match_hostname(self.sock.getpeercert(), server_hostname)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except Exception:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.sock.shutdown(socket.SHUT_RDWR)
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 407, in wrap_socket

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  server_hostname=None, session=None):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return SSLSocket(sock=sock, server_side=server_side,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  do_handshake_on_connect=do_handshake_on_connect,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  suppress_ragged_eofs=suppress_ragged_eofs,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  server_hostname=server_hostname,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  _context=self, _session=session)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def wrap_bio(self, incoming, outgoing, server_side=False,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  server_hostname=None, session=None):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  sslobj = self._wrap_bio(incoming, outgoing, server_side=server_side,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  server_hostname=server_hostname)
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 814, in __init__

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if do_handshake_on_connect:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  timeout = self.gettimeout()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if timeout == 0.0:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # non-blocking
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.do_handshake()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except (OSError, ValueError):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.close()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1068, in do_handshake

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._check_connected()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  timeout = self.gettimeout()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if timeout == 0.0 and block:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.settimeout(None)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._sslobj.do_handshake()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  finally:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.settimeout(timeout)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def _real_connect(self, addr, connect_ex):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if self.server_side:
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 689, in do_handshake

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """Return the number of bytes that can be read immediately."""
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return self._sslobj.pending()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def do_handshake(self):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """Start the SSL/TLS handshake."""
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._sslobj.do_handshake()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if self.context.check_hostname:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if not self.server_hostname:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise ValueError("check_hostname needs server_hostname "
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  "argument")
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  match_hostname(self.getpeercert(), self.server_hostname)
  • During handling of the above exception, another exception occurred:
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self.base_url = urlparse(self.get_base_url())
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  super().__init__()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def __call__(self, environ, start_response):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if not self._should_handle(get_path_info(environ)):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return self.application(environ, start_response)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return super().__call__(environ, start_response)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")class ASGIStaticFilesHandler(StaticFilesHandlerMixin, ASGIHandler):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def __call__(self, environ, start_response):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  set_script_prefix(get_script_name(environ))
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  signals.request_started.send(sender=self.__class__, environ=environ)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  request = self.request_class(environ)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = self.get_response(request)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response._handler_class = self.__class__
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  status = '%d %s' % (response.status_code, response.reason_phrase)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response_headers = [
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/base.py", line 75, in get_response

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def get_response(self, request):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """Return an HttpResponse object for the given HttpRequest."""
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # Setup default url resolver for this thread
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  set_urlconf(settings.ROOT_URLCONF)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = self._middleware_chain(request)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response._resource_closers.append(request.close)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if response.status_code >= 400:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  log_response(
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  '%s: %s', response.reason_phrase, request.path,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response=response,
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  @wraps(get_response)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def inner(request):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = get_response(request)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except Exception as exc:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = response_for_exception(request, exc)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return response
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return inner
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")def response_for_exception(request, exc):
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # Allow sys.exit() to actually exit. See tickets #1023 and #4701
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  else:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  signals.got_request_exception.send(sender=None, request=request)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  log_response(
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  '%s: %s', response.reason_phrase, request.path,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response=response,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  request=request,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  exc_info=sys.exc_info(),
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if settings.DEBUG_PROPAGATE_EXCEPTIONS:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if settings.DEBUG:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return debug.technical_500_response(request, *exc_info)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # Return an HttpResponse that displays a friendly error message.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  callback, param_dict = resolver.resolve_error_handler(500)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return callback(request, **param_dict)
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 37, in null_technical_500_response

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  elif tld.wsgi_tb:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  tb = tld.wsgi_tb
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except AttributeError:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  pass
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  six.reraise(exc_type, exc_value, tb)
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/six.py", line 702, in reraise

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def reraise(tp, value, tb=None):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if value is None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  value = tp()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if value.__traceback__ is not tb:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise value.with_traceback(tb)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise value
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  finally:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  value = None
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  tb = None
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  can rely on getting a response instead of an exception.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  """
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  @wraps(get_response)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def inner(request):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = get_response(request)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except Exception as exc:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = response_for_exception(request, exc)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return response
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return inner
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if response is None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  wrapped_callback = self.make_view_atomic(callback)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = wrapped_callback(request, *callback_args, **callback_kwargs)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except Exception as e:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = self.process_exception_by_middleware(e, request)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # Complain if the view returned None (a common error).
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if response is None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if isinstance(callback, types.FunctionType):    # FBV
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  view_name = callback.__name__
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  break
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if response is None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  wrapped_callback = self.make_view_atomic(callback)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = wrapped_callback(request, *callback_args, **callback_kwargs)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except Exception as e:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = self.process_exception_by_middleware(e, request)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # Complain if the view returned None (a common error).
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if response is None:
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def decorator(view_func):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  @wraps(view_func)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def _wrapped_view(request, *args, **kwargs):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if test_func(request.user):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return view_func(request, *args, **kwargs)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  path = request.build_absolute_uri()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  resolved_login_url = resolve_url(login_url or settings.LOGIN_URL)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # If the login url is the same scheme and net location then just
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # use the path as the "next" url.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  login_scheme, login_netloc = urlparse(resolved_login_url)[:2]
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/bookmarks/images/views.py", line 15, in image_create

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # form is sent
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  form = ImageCreateForm(data=request.POST)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if form.is_valid():
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # form data is valid
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  cd = form.cleaned_data
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  new_item = form.save(commit=False)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # assign current user to the item
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  new_item.user = request.user
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  new_item.save()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  messages.success(request, 'Image added successfully')
  • File "/Users/dpthegrey/PROJECTS/django3_social_website/bookmarks/images/forms.py", line 38, in save

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  name = slugify(image.title)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  extension = image_url.rsplit('.', 1)[1].lower()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  image_name = f'{name}.{extension}'
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # download image from the given URL
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = request.urlopen(image_url)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  image.image.save(image_name,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  ContentFile(response.read()),
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  save=False)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if commit:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  image.save()
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  opener = build_opener(https_handler)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  elif _opener is None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  _opener = opener = build_opener()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  else:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  opener = _opener
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return opener.open(url, data, timeout)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")def install_opener(opener):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  global _opener
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  _opener = opener
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  meth_name = protocol+"_request"
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  for processor in self.process_request.get(protocol, []):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  meth = getattr(processor, meth_name)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  req = meth(req)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  response = self._open(req, data)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # post-process response
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  meth_name = protocol+"_response"
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  for processor in self.process_response.get(protocol, []):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  meth = getattr(processor, meth_name)
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if result:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return result
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  protocol = req.type
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  result = self._call_chain(self.handle_open, protocol, protocol +
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  '_open', req)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if result:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return result
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return self._call_chain(self.handle_open, 'unknown',
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  'unknown_open', req)
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # the request, or return None if they can't but another handler
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # could.  Otherwise, they return the response.
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  handlers = chain.get(kind, ())
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  for handler in handlers:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  func = getattr(handler, meth_name)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  result = func(*args)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  if result is not None:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return result
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  # accept a URL or a Request object
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._context = context
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  self._check_hostname = check_hostname
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  def https_open(self, req):
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  return self.do_open(http.client.HTTPSConnection, req,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  context=self._context, check_hostname=self._check_hostname)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  https_request = AbstractHTTPHandler.do_request_
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  __all__.append('HTTPSHandler')
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 
  • File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open

    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  try:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  h.request(req.get_method(), req.selector, req.data, headers,
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  encode_chunked=req.has_header('Transfer-encoding'))
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except OSError as err: # timeout error
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise URLError(err)
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  r = h.getresponse()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  except:
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  h.close()
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame")  raise
    ![](https://mysite.com:8000/images/create/?__debugger__=yes&cmd=resource&f=console.png "Open an interactive python shell in this frame") 

urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)>

This is the Copy/Paste friendly version of the traceback. You can also paste this traceback into a gist:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1400, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return self.application(environ, start_response)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
    response = self.get_response(request)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/base.py", line 75, in get_response
    response = self._middleware_chain(request)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 37, in null_technical_500_response
    six.reraise(exc_type, exc_value, tb)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/six.py", line 702, in reraise
    raise value.with_traceback(tb)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/env/bookmarks/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/bookmarks/images/views.py", line 15, in image_create
    new_item = form.save(commit=False)
  File "/Users/dpthegrey/PROJECTS/django3_social_website/bookmarks/images/forms.py", line 38, in save
    response = request.urlopen(image_url)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: 
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

  • dump() shows all variables in the frame
  • dump(obj) dumps all that's known about the object

Brought to you by **DON'T PANIC**, your friendly Werkzeug powered traceback interpreter.

Console Locked

The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.

PIN:

Installing PostgreSQL on Windows 7 Chapter 3

Wow! I've reached the chapter 3 and there was a problem I couldn't have dealt with.

The author asks readers to run the following commands:

su postgres
createuser -dP blog

I wonder.... if he tried to run the commands himself? I spent many hours trying to understand how it works.

I found the same issue in stackoverflow
https://stackoverflow.com/questions/53672593/using-postgres-shell-to-createuser

many other tutorials like..... change your password in .pgpass or pgpass.conf which is located at %APPDATA%\postgresql\ - actually it isn't! Then I read a dozen other tutorials how to create a user .... bla-bla-bla-bla! Nothing has work!

Eventually, I did as I'd done when I was reading Django for Professionals by William S. Vincent.

Once you clicked on PostgreSQL's install it will ask you for a password. Type: postgres
When it finishes installing the database go to settings.py of your project, comment out the older one

# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.sqlite3',
#         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#     }
# }

and paste the text:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'postgres',
        'USER': 'postgres',
        'PASSWORD': 'postgres',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

That's it! I've saved your time! Now you owe me!

Chapter 9 suggestion:

Chapter 9 Suggestion:
products_bought method from recommender.py is nowhere being called.

Suggestion to add in tasks.py the following code:

order = Order.objects.get(id=order_id)
order_items = order.items.all()
products = []

for oi in order_items:
products.append(oi.product)

recommender = Recommender()
recommender.products_bought(products)

[C4,P106] Found Typo in base.html

The author asks his readers to add some lines into base.html when we use a build-in Django authentication log in and log out views:

Here's the snippet of code in base.html, basically, you have to change:
Hello {{ request.user.first_name}}, to Hello {{ request.user.username}},

        <span class="user">
            {% if request.user.is_authenticated %}
                #Hello {{ request.user.first_name}}, # Typo.
                Hello {{ request.user.username}},
                <a href="{% url 'logout' %}">Logout</a>
            {% else %}
                <a href="{% url 'login' %}">Login</a>
            {% endif %}
        </span>

page106

One won't get an error however it would be displayed "Hello, Logout".

p.s. #page 107, typo in the following text: You display the user's first name and a link to log out if the user is authenticated, or a link to log in otherwise

Image Likes

I have found that when a user without a profile photo likes an image the following error occurs "photo attribute has no file associated with it"

Anyone else?

cd variable in Bookmarks

There is a cd variable assigned in bookmarks/images/views.py but never used. Is there any reason for it???

User has no profile. I am getting this error when I am trying to run http://127.0.0.1:8000/account/edit/

I am working on t chapter 4 section Extending the user model. I do not have any idea where profile from profile_form = ProfileEditForm(instance=request.user.profile, data=request.POST, files=request.FILES) is coming from. Moreover, when I tried to run it I am getting error User has no profile. I have followed each and every steps according to section Extending the user model.Please help. Thanks

Chapter 9: Error

Chapter 9 throws an error if all the products from the cart are removed.
The following should be added to recommender.py

def suggest_products_for(self, products, max_results=6):
product_ids = [p.id for p in products]

Add this to solve the bug

if len(products) == 0:
return []

How does Django knows which template to render when?

I am on 4th chapter the book Django 3 by example and I noticed one thing that we are only creating views from Django's authentication framework but we are not telling those views which template to render when.
For example, how does my application would know that it needs to only render the logged_out.html template when we try to access the logout view? If I try to change the name of the file from logged_out.html to loggedout.html then it takes me to the Django's admin logout page.

Why?

Wrong CSS files for Chapter 7

The CSS files included in chapter 7 in this code don't conform to the ones shown in the images examples from the book. The CSS files present in the code for Chapter 7 are the same used in Chapters 5 and 6.

Could I have the CSS files for Chapter 7?

chapter 10 AttributeError: module 'django.apps' has no attribute 'get_model'

Wat could cause this?
Traceback Switch to copy-and-paste view

t/Software_project/educa/venv/lib/python3.8/site-packages/django/core/handlers/exception.py, line 47, in inner
response = get_response(request) …
▶ Local vars
Software_project/educa/venv/lib/python3.8/site-packages/django/core/handlers/base.py, line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) …
▶ Local vars
/Software_project/educa/venv/lib/python3.8/site-packages/django/views/generic/base.py, line 73, in view
return self.dispatch(request, *args, **kwargs) …
▶ Local vars
oftware_project/educa/courses/views.py, line 110, in dispatch
self.model = self.get_model(model_name) …
▶ Local vars
t/Software_project/educa/courses/views.py, line 95, in get_model
return apps.get_model(app_label='courses', …
▶ Local vars

Using Memcached on Windows

Provide instructions for windows users to install and run Memcached

On pg433 "Installing Memcached", it directs the user to install Memcached, but only provides instructions for Mac/Linux.

After some research, I found that Memcached is not officialy supported on Windows. My first thought was that as a windows user, I wouldn't be able to participate in this part of the book. However, there are work-arounds, and the one that I found was to use the same WSL (Windows Subsystem Linux) that I used during the Redis portion of the book to also install and run memcached (Another alternative is using a memcached binary file, but the terminal method just seemed more appropriate). This also made me realize that I can use WSL as a tool to run various linux services as well as familiarize myself with the terminal as a whole.

Instructions

  1. Start the WSL terminal: The book provided a link to RedisLabs, which had instructions on settings up WSL (pg215). You used it to install and run the Redis Daemon (AKA, Redis service).
  2. Update your package manager listing: I chose to install Debian as my WSL, so for me the command was...
    sudo apt-get update
  3. Install Memcached: Again, I'm using Debian, and the command was...
    sudo apt-get install memcached
  4. Run memcached: Use the same Linux command that is provided in the book (The terminal will hang while the service is running, but you can stop it with CTRL + C)...
    memcached -l 127.0.0.1:11211
  5. (Optional) Run as deamon: If you want memcached to run in the background so you have access to the terminal, you can add the -d flag to the command.
    memcached -d -l 127.0.0.1:11211
    To stop the daemon, look up the process id using the command pos aux and then enter kill id

The only issue I had with it was that once you add memcached monitoring to the to the admin site, the bar graph is always red (which means full) however the stats below it prove otherwise.
Looks like this is a problem with the django-memcache-status package. However, Antonio has already made a pull-request to fix it. Editing the file manually works until the request can be merged and a new release is made.

P.S
Almost done with the book and its been AMAZING! Gracias Antonio, aprendí bastante y voy a seguir usando el libro para referencia!

Chap 7: Quantity field unavailable

everything is working fine in chapter 7 but the quantity variable is not working, i mean except quantity option/field every other field (name, category, price, description) is visible on the detail page. Please help!

social auth does not create user profile

I went through the building a social site chapter. Facebook, Twitter, Goolge will let me create Bookmark user accounts but since it bypasses registration a user profile doesn't get made. Where do we create the user profile when social auth is used?

Chapter 3: 404-error when accessing blog homepage

I'm getting a 404 error when accessing the homepage at URL http://127.0.0.1/. The only way I can get to the post list is by going to http://127.0.0.1/blog. The code is identical to the code in this GitHub repository. I tried the code on Window 10 and Ubuntu Linux 18.04 and got the same results. I am using Python 3.8.5 and Django 3.0.10.

This is a screenshot of the error message:

404-error

mysite/urls.py

"""mysite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.contrib.sitemaps.views import sitemap
from blog.sitemaps import PostSitemap

sitemaps = {
    'posts': PostSitemap,
}

urlpatterns = [
    path('admin/', admin.site.urls),
    path('blog/', include('blog.urls', namespace='blog')),
    path('sitemap.xml', sitemap, {'sitemaps': sitemaps},
         name='django.contrib.sitemaps.views.sitemap')
]

blog/urls.py

from django.urls import path
from . import views
from .feeds import LatestPostsFeed

app_name = 'blog'

urlpatterns = [
    # post views
    path('', views.post_list, name='post_list'),
    path('tag/<slug:tag_slug>/', views.post_list, name='post_list_by_tag'),
    # path('', views.PostListView.as_view(), name='post_list'),
    path('<int:year>/<int:month>/<int:day>/<slug:post>/', views.post_detail, name='post_detail'),
    path('<int:post_id>/share/', views.post_share, name='post_share'),
    path('feed/', LatestPostsFeed(), name='post_feed'),
    path('search/', views.post_search, name='post_search'),
]

blog/views.py

from django.db.models import Count
from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator, EmptyPage,\
                                  PageNotAnInteger
from django.core.mail import send_mail
from django.views.generic import ListView
from django.contrib.postgres.search import SearchVector, SearchQuery, SearchRank
from django.contrib.postgres.search import TrigramSimilarity
from .models import Post, Comment
from .forms import EmailPostForm, CommentForm, SearchForm
from taggit.models import Tag


def post_list(request, tag_slug=None):
    object_list = Post.published.all()
    tag = None

    if tag_slug:
        tag = get_object_or_404(Tag, slug=tag_slug)
        object_list = object_list.filter(tags__in=[tag])

    paginator = Paginator(object_list, 3) # 3 posts in each page
    page = request.GET.get('page')
    try:
        posts = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer deliver the first page
        posts = paginator.page(1)
    except EmptyPage:
        # If page is out of range deliver last page of results
        posts = paginator.page(paginator.num_pages)
    return render(request,
                 'blog/post/list.html',
                 {'page': page,
                  'posts': posts,
                  'tag': tag})


def post_detail(request, year, month, day, post):
    post = get_object_or_404(Post, slug=post,
                                   status='published',
                                   publish__year=year,
                                   publish__month=month,
                                   publish__day=day)

    # List of active comments for this post
    comments = post.comments.filter(active=True)

    new_comment = None

    if request.method == 'POST':
        # A comment was posted
        comment_form = CommentForm(data=request.POST)
        if comment_form.is_valid():
            # Create Comment object but don't save to database yet
            new_comment = comment_form.save(commit=False)
            # Assign the current post to the comment
            new_comment.post = post
            # Save the comment to the database
            new_comment.save()
    else:
        comment_form = CommentForm()

    # List of similar posts
    post_tags_ids = post.tags.values_list('id', flat=True)
    similar_posts = Post.published.filter(tags__in=post_tags_ids)\
                                  .exclude(id=post.id)
    similar_posts = similar_posts.annotate(same_tags=Count('tags'))\
                                .order_by('-same_tags','-publish')[:4]

    return render(request,
                  'blog/post/detail.html',
                  {'post': post,
                   'comments': comments,
                   'new_comment': new_comment,
                   'comment_form': comment_form,
                   'similar_posts': similar_posts})


class PostListView(ListView):
    queryset = Post.published.all()
    context_object_name = 'posts'
    paginate_by = 3
    template_name = 'blog/post/list.html'


def post_share(request, post_id):
    # Retrieve post by id
    post = get_object_or_404(Post, id=post_id, status='published')
    sent = False

    if request.method == 'POST':
        # Form was submitted
        form = EmailPostForm(request.POST)
        if form.is_valid():
            # Form fields passed validation
            cd = form.cleaned_data
            post_url = request.build_absolute_uri(post.get_absolute_url())
            subject = f"{cd['name']} recommends you read {post.title}"
            message = f"Read {post.title} at {post_url}\n\n" \
                      f"{cd['name']}\'s comments: {cd['comments']}"
            send_mail(subject, message, '[email protected]', [cd['to']])
            sent = True

    else:
        form = EmailPostForm()
    return render(request, 'blog/post/share.html', {'post': post,
                                                    'form': form,
                                                    'sent': sent})


def post_search(request):
    form = SearchForm()
    query = None
    results = []
    if 'query' in request.GET:
        form = SearchForm(request.GET)
        if form.is_valid():
            query = form.cleaned_data['query']
            results = Post.published.annotate(
                similarity=TrigramSimilarity('title', query),
            ).filter(similarity__gt=0.1).order_by('-similarity')
    return render(request,
                  'blog/post/search.html',
                  {'form': form,
                   'query': query,
                   'results': results})

Let me know if you need additional information. Thanks

Chapter 10. AttributeError: 'Module' object has no attribute 'courses'

So... I am having this problem where whenever I try to add a Module to a Course, I get an attribute error: "Module' object has no attribute 'courses'".

For the life of me, I cannot figure out what I did wrong. I looked through all my views in courses/views.py and everything seems right...Where is this problem stemming from?

File "C:\Users\tilli\Desktop\projects\educa\courses\fields.py", line 19, in pre_save for field in self.for_fields}

File "C:\Users\tilli\Desktop\projects\educa\courses\fields.py", line 19, in <dictcomp> for field in self.for_fields}

AttributeError: 'Module' object has no attribute 'courses'

I am, however, able to add new Modules through Django Admin

Password Resetting view displays the django framework template - Chapter )4

Even after adding template name in my urls.py, I still don't get any improvement

from django.urls import path
from .views import UserRegisterView, AddProductView, CategoryView, UserEditView, PasswordsChangeView
from django.contrib.auth import views as auth_views
from . import views
from .views import *

app_name = 'members'

urlpatterns = [
    # path('signup/', UserRegisterView.as_view(), name='signup'),
    # path('account/', UserEditView.as_view(), name='edit_account'),
    path('account/', views.edit, name='edit_account'),
    path('signup/', views.signup, name='signup'),
    path('activate/<slug:uidb64>/<slug:token>/', views.activate, name='activate'),
    # path('password/', auth_views.PasswordChangeView.as_view(template_name='registration/change_password.html')),
    path('password/', PasswordsChangeView.as_view(template_name='registration/change_password.html'), name='password'),
    path('add_product/', AddProductView.as_view(), name='add_product'),
    path('add_category/', CategoryView.as_view(), name='add_category'),
    path('password_reset/', auth_views.PasswordResetView.as_view(template_name='registration/password_reset.html'),
         name='password_reset'),
    path('password_reset/done/',
         auth_views.PasswordResetDoneView.as_view(template_name='registration/password_reset_done.html'),
         name='password_reset_done'),
    path('reset/<uidb64>/<token>/',
         auth_views.PasswordResetConfirmView.as_view(template_name='registration/password_reset_confirm.html'),
         name='password_reset_confirm'),
    path('reset/done/',
         auth_views.PasswordResetCompleteView.as_view(template_name='registration/password_reset_complete.html'),
         name='password_reset_complete'),
]

It only works for this path('password_reset/', auth_views.PasswordResetView.as_view(template_name='registration/password_reset.html'), name='password_reset'),
Thanks for your help

Can't create orders app

I am in the section Registering customer orders and when I run the command python manage.py startapp orders I get the error: CommandError: 'orders' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
Someone with the same problem? How can I solve that? Thanks.

ModuleNotFoundError: No module named 'account.authentication'

In chapter 4 your add
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'account.authentication.EmailAuthBackend',
]

this gives me the following error
ModuleNotFoundError: No module named 'account.authentication'
When I remove AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'account.authentication.EmailAuthBackend',
] I can login with password and username

this workes
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
]

this does not
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'account.authentication.EmailAuthBackend',
]

https://github.com/PacktPublishing/Django-3-by-Example/blob/master/Chapter04/bookmarks/bookmarks/settings.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.