python-django.json 3.8 KB

123456
  1. {
  2. "html": "<div class=\"section\" id=\"installation\">\n<h2>Installation</h2>\n<p>If you haven&#8217;t already, start by downloading Raven. The easiest way is\nwith <em>pip</em>:</p>\n<div class=\"highlight-python\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span>pip install raven --upgrade\n</pre></div>\n</div>\n</div>\n\n\n<div class=\"section\" id=\"setup\">\n<h2>Setup</h2>\n<p>Using the Django integration is as simple as adding\n<code class=\"xref py py-mod docutils literal\"><span class=\"pre\">raven.contrib.django.raven_compat</span></code> to your installed apps:</p>\n<div class=\"highlight-python\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #111111\">INSTALLED_APPS</span> <span style=\"color: #4b4f5c\">=</span> <span style=\"color: #111111\">(</span>\n <span style=\"color: #e8535a\">&#39;raven.contrib.django.raven_compat&#39;</span><span style=\"color: #111111\">,</span>\n<span style=\"color: #111111\">)</span>\n</pre></div>\n</div>\n<div class=\"admonition note\">\n<p class=\"first admonition-title\">Note</p>\n<p class=\"last\">This causes Raven to install a hook in Django that will\nautomatically report uncaught exceptions.</p>\n</div>\n<p>Additional settings for the client are configured using the\n<code class=\"docutils literal\"><span class=\"pre\">RAVEN_CONFIG</span></code> dictionary:</p>\n<div class=\"highlight-python\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #2eb0f7\">import</span> <span style=\"color: #111111\">os</span>\n<span style=\"color: #2eb0f7\">import</span> <span style=\"color: #111111\">raven</span>\n\n<span style=\"color: #111111\">RAVEN_CONFIG</span> <span style=\"color: #4b4f5c\">=</span> <span style=\"color: #111111\">{</span>\n <span style=\"color: #e8535a\">&#39;dsn&#39;</span><span style=\"color: #111111\">:</span> <span style=\"color: #e8535a\">&#39;___DSN___&#39;</span><span style=\"color: #111111\">,</span>\n <span style=\"color: #34c08b; font-style: italic\"># If you are using git, you can also automatically configure the</span>\n <span style=\"color: #34c08b; font-style: italic\"># release based on the git info.</span>\n <span style=\"color: #e8535a\">&#39;release&#39;</span><span style=\"color: #111111\">:</span> <span style=\"color: #111111\">raven</span><span style=\"color: #4b4f5c\">.</span><span style=\"color: #111111\">fetch_git_sha(os</span><span style=\"color: #4b4f5c\">.</span><span style=\"color: #111111\">path</span><span style=\"color: #4b4f5c\">.</span><span style=\"color: #111111\">abspath(os</span><span style=\"color: #4b4f5c\">.</span><span style=\"color: #111111\">pardir)),</span>\n<span style=\"color: #111111\">}</span>\n</pre></div>\n</div>\n<p>Once you&#8217;ve configured the client, you can test it using the standard Django\nmanagement interface:</p>\n<div class=\"highlight-python\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span>python manage.py raven test\n</pre></div>\n</div>\n<p>You&#8217;ll be referencing the client slightly differently in Django as well:</p>\n<div class=\"highlight-python\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #2eb0f7\">from</span> <span style=\"color: #111111\">raven.contrib.django.raven_compat.models</span> <span style=\"color: #2eb0f7\">import</span> <span style=\"color: #111111\">client</span>\n\n<span style=\"color: #111111\">client</span><span style=\"color: #4b4f5c\">.</span><span style=\"color: #111111\">captureException()</span>\n</pre></div>\n</div>\n</div>\n",
  3. "link": "https://docs.getsentry.com/clients/python/integrations/django/",
  4. "id": "python-django",
  5. "name": "Django"
  6. }