├── .gitignore
├── LICENSE
├── README.md
├── django_stackoverflow_trace
└── __init__.py
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | env/
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 |
27 | # PyInstaller
28 | # Usually these files are written by a python script from a template
29 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
30 | *.manifest
31 | *.spec
32 |
33 | # Installer logs
34 | pip-log.txt
35 | pip-delete-this-directory.txt
36 |
37 | # Unit test / coverage reports
38 | htmlcov/
39 | .tox/
40 | .coverage
41 | .coverage.*
42 | .cache
43 | nosetests.xml
44 | coverage.xml
45 | *,cover
46 | .hypothesis/
47 |
48 | # Translations
49 | *.mo
50 | *.pot
51 |
52 | # Django stuff:
53 | *.log
54 |
55 | # Sphinx documentation
56 | docs/_build/
57 |
58 | # PyBuilder
59 | target/
60 |
61 | #Ipython Notebook
62 | .ipynb_checkpoints
63 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Emre Yılmaz
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | django-stackoverflow-trace
2 | ================
3 |
4 | A custom Django technical error template that puts a related stackoverflow search link under the exception message.
5 |
6 | ### Installation
7 |
8 | ```bash
9 | $ (sudo) pip install django_stackoverflow_trace
10 | ```
11 |
12 | ### Setting it up
13 |
14 | Add the custom middleware to your ```MIDDLEWARE_CLASSES``` in the **settings.py**.
15 |
16 |
17 | ```python
18 | if DEBUG:
19 | MIDDLEWARE_CLASSES += ('django_stackoverflow_trace.DjangoStackoverTraceMiddleware', )
20 | ```
21 |
22 | Next time you hit an error in your app, you will see an external link to a custom google search.
23 |
24 |
25 |
26 | ### Using google search instead of stackoverflow
27 |
28 | Add this into your settings.py
29 |
30 | ```DJANGO_STACKOVERFLOW_TRACE_SEARCH_SITE = "googlesearch"```
31 |
32 |
--------------------------------------------------------------------------------
/django_stackoverflow_trace/__init__.py:
--------------------------------------------------------------------------------
1 | from django.views import debug
2 | from django.conf import settings
3 |
4 |
5 | def get_search_link():
6 | default_choice = "stackoverflow"
7 |
8 | search_urls = {
9 | "stackoverflow": "http://stackoverflow.com/search?q=[python] or "
10 | "[django]+{{ exception_value|force_escape }}",
11 | "googlesearch": "https://www.google.com.tr/#q="
12 | "+django+{{ exception_value|force_escape }}"
13 | }
14 |
15 | search_url = getattr(
16 | settings,
17 | 'DJANGO_STACKOVERFLOW_TRACE_SEARCH_SITE',
18 | default_choice
19 | )
20 |
21 | return search_urls.get(search_url, search_urls[default_choice])
22 |
23 |
24 | def _patch_django_debug_view():
25 |
26 | new_data = """
27 |