"Youtube watch link to embed" custom tag.
Tag for simple embed video from youtube watch link. It can be modified to manage size of embedded video.
- youtube
- embed
- custom-tag
Tag for simple embed video from youtube watch link. It can be modified to manage size of embedded video.
This code allows you to upload a mp3 to the Admin Frontend. The ID3 tags are automatically read out and filled in to the according fields. This should work for other filetypes as well. As long as they have an id3 tag.
To use it, append all your model save methods with a IntegrityError catcher.
Simple password validation for user registration - requires that password be 7 or more characters and contain both letters and numbers. Original validation with regex approach developed by kurtis. Optimized no-regex version based on code from watchedman ran as fast or significantly faster on all systems on which we tested it.
This manager is based on the economical method of randomization. It usable in related models. For support this behavior required to be defined as default manger.
Generic class view to abstract out the task of serving up files from within Django. Recommended usage is to combine it with SingleObjectMixin and extend certain methods based on your particular use case. Example usage class Snippet(models.Model): name = models.CharField(max_length = 100) slug = SlugField() code = models.TextField() from django.views.generic.detail import SingleObjectMixin class DownloadSnippetView(SingleObjectMixin, DownloadView): model = Snippet use_xsendfile = False mimetype = 'application/python' def get_contents(self): return self.get_object().code def get_filename(self): return self.get_object().slug + '.py' '''
Because select_related() only works on ForeignKeys that are not null or blank, when you are customizing the admin, even if you set "list_select_related=True" you can still end up with way too many querys in the Admin changelist. By adding this code to your model you can decrease the queries dramatically. I found I needed this when I was working with Django apps with a lot of legacy data and I couldn't set the ForeignKey null=False.
By default the `runserver` command does some magic to automatically serve admin media. This magic doesn't happen when using other servers like gunicorn… But this makes that magic unnecessary by using urls.py to route requests for admin media to the standard static media server. `#include <production_disclaimer.h>`
A project I'm working on requires multiple different classes of users, all with different fields/attributes. Having a single UserProfile class with a generic relation was a complete pain in practice. So, I changed my classes to all subclass User directly and then used django-model-utils to create a custom ModelBackend that returns the appropriate class when accessing request.user. The InheritanceQuerySet manager provided by django-model-utils makes it all possible and with only a single database query. No need to add anything directly to the User class, by the way. Just subclass it directly with each of your custom classes: class CustomUser1(User): field1 = models.CharField(...) class CustomUser2(User): field2 = models.CharField(...)
This template tag will duplicate its contents according to a variable or integer supplied to it. {% duplicate 3 %}a{% endduplicate %} This would return: > aaa
This math captcha field and widget was inspired by Justin Quick's django-math-captcha, but I wanted to make it into one form field and not have anything in settings.py. I removed the division and modulo operators to avoid people having to input fractions, and just randomly select the operator. It leverages Django's built-in MultiValueField to set up the hidden hashed answer to compare the user's input to instead of rendering strings for the fields like django-math-captcha does. Unit tests soon to follow, but this is used in production at: http://btaylorweb.com/. Enjoy!
You can use this class for render and send html email message with the same logic and facility of website page creation. Just create an html template file with the same name of Class in lowercase.
There are cases when rendering had already started, but you have to return Your response nevertheless. A good example is when you have a django-cms plugin and a form in it. You want to redirect after the form was processed, but normally you can't do it. More information here: https://github.com/divio/django-cms/issues/79 http://groups.google.com/group/django-cms/browse_thread/thread/79ab6080c80bbcb5?pli=1
View mixin and utils to generate PDF documents from html using *xhtml2pdf*. The most interesting thing here is *PDFTemplateResponseMixin*. Adding this mixin to class based views allows automatic pdf generation using the view context and a customized template. There is also the lower level function *render_to_pdf*, similar to what can be seen in [snippet 659](http://djangosnippets.org/snippets/659/). See the docstrings for a detailed explanation.
A collection of utilities for admin log entries management. This module provides functions to add log entries for instance addition, change and deletion, as seen in *django.contrib.admin.options*. It also provides a class based view mixin to add logging capabilities, and other tools as a log collector. See docstrings for a better description.
2955 snippets posted so far.