djangosnippets.org: Latest snippets tagged with 'content-type'https://djangosnippets.org/tags/content-type/2018-01-14T21:42:58.502236-06:00Content type to get Model
2018-01-14T21:42:58.502236-06:00agusmakmunhttps://djangosnippets.org/snippets/10634/<p>Instance class model with <code>class ModelName(models.Model, ContentTypeToGetModel):</code></p>
Freely redistributableCustom FileField with content type and size validation
2010-09-24T07:58:13.925699-05:00nemesishttps://djangosnippets.org/snippets/2206/<p>Usage described in this blog post: <a href="http://nemesisdesign.net/blog/coding/django-filefield-content-type-size-validation/">Django: FileField with ContentType and File Size Validation</a></p>
<p>Snippet inspired by: <a href="http://djangosnippets.org/snippets/1303/">Validate by file content type and size</a></p>
Freely redistributableURL models
2009-10-09T18:11:07.721923-05:00divermanhttps://djangosnippets.org/snippets/1755/<p>You can use <code>UrlModel</code> to provide URL functionality to any instance of any model and any language (language support can be removed from this). Each model must have own view method, that returns HttpResponse. I was inspired by Flatpages. It is useful for small sites and static pages.</p>
<pre><code>`class Page(UrlModel): …</code></pre>
Freely redistributableChild aware model inheritance
2008-11-14T10:14:12.237993-06:00rixhttps://djangosnippets.org/snippets/1187/<p>Base models aren't aware of its inherited models, here is a quick solution to access child models from the base model.</p>
Freely redistributable