Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

Django unique _together for foreign keys

1
2
3
4
def validate_unique(self, exclude=None):
	 	qs = Vendoroffer.objects.filter(vendor=self.vendor)
	 	if qs.filter(product__slug = self.product__slug).exists():
	 		raise ValidationError('Product already posted by vendor')
https://snipt.net/embed/a2e497b8eeb1155e37d151bf0320529d/
https://snipt.net/raw/a2e497b8eeb1155e37d151bf0320529d/
a2e497b8eeb1155e37d151bf0320529d
text
Text only
4
2016-12-05T17:28:26
True
False
False
/api/public/snipt/113279/
django-unique-_together-for-foreign-keys
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>def validate_unique(self, exclude=None): </span><span id="L-2"><a name="L-2"></a> qs = Vendoroffer.objects.filter(vendor=self.vendor) </span><span id="L-3"><a name="L-3"></a> if qs.filter(product__slug = self.product__slug).exists(): </span><span id="L-4"><a name="L-4"></a> raise ValidationError(&#39;Product already posted by vendor&#39;) </span></pre></div> </td></tr></table>
django

Python

Django logout and redirect url.

url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}),
https://snipt.net/embed/edcf9a4f64ef489e42e595a4a3538cec/
https://snipt.net/raw/edcf9a4f64ef489e42e595a4a3538cec/
edcf9a4f64ef489e42e595a4a3538cec
python
Python
2
2016-12-06T16:12:37
True
False
False
Dec 04, 2013 at 11:51 AM
/api/public/snipt/98547/
django-logout-and-redirect-url
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">url</span><span class="p">(</span><span class="s1">r&#39;^logout/$&#39;</span><span class="p">,</span> <span class="s1">&#39;django.contrib.auth.views.logout&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;next_page&#39;</span><span class="p">:</span> <span class="s1">&#39;/&#39;</span><span class="p">}),</span> </span></pre></div> </td></tr></table>
django, logout

Bash

Twoscoop's django project template

django-admin.py startproject --template=https://github.com/twoscoops/django-twoscoops-project/zipball/master --extension=py,rst,html
https://snipt.net/embed/02e6f9ff38ca784cd5dee065f3a4c0b0/
https://snipt.net/raw/02e6f9ff38ca784cd5dee065f3a4c0b0/
02e6f9ff38ca784cd5dee065f3a4c0b0
bash
Bash
1
2016-12-05T16:51:22
True
False
False
Apr 14, 2013 at 10:29 AM
/api/public/snipt/59295/
twoscoops-django-project-template
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>django-admin.py startproject --template<span class="o">=</span>https://github.com/twoscoops/django-twoscoops-project/zipball/master --extension<span class="o">=</span>py,rst,html </span></pre></div> </td></tr></table>
django
Copyrighted, illegal, or inappropriate content? Email [email protected].