djangosnippets.org: Latest snippets tagged with 'magic'https://djangosnippets.org/tags/magic/2021-03-24T08:52:02.850184-05:00"Magic Link" Management Command
2021-03-24T08:52:02.850184-05:00webologyhttps://djangosnippets.org/snippets/10855/<p>Django Management Command to print a "Magic Link" for one-click log-in. This is nice for people who project switch or don't want to remember passwords.</p>
Freely redistributableFile Mimetype Validator (Using python-magic)
2014-04-01T18:02:23.248100-05:00BHSPitMonkeyhttps://djangosnippets.org/snippets/3039/<p>This validator works well with FileField form fields and can validate that an uploaded file has an acceptable mimetype. Place this snippet in your app's <code>validators.py</code>.</p>
<p>Requirements:</p>
<p>This snippet uses <a href="https://github.com/ahupp/python-magic">python-magic</a>. To install:</p>
<pre><code>pip install python-magic
</code></pre>
<p>Usage (in forms.py):</p>
<pre><code>from validators import MimetypeValidator
class MyForm(forms.Form):
file = forms.FileField( …</code></pre>
Freely redistributablemanage.py with magic python path
2007-06-13T05:33:23.747987-05:00bikeshedderhttps://djangosnippets.org/snippets/281/<p>I tend to have all my python code together in a 'python' directory.
</p>
<p>e.g. a typical project layout of mine looks like:
</p>
<pre><code>/python
/python/myproject - project python code
/python/django - local copy of django
/python/foolib - some third party library
/media
/templates
...
</code></pre><p>Since I don't want to set the …</p>
Freely redistributable