Cookbook | Packages | Tests | Presentations | Django suit | South | URL reversing and namespace | Logging | Factory | Celery
- http://andrewsforge.com/article/upgrading-django-to-17/part-3-django-17-new-features/
- http://www.markus-gattol.name/ws/python_web.html
- http://djangozen.com/
- http://agiliq.com/books/djangodesignpatterns/
- http://www.stereoplex.com/blog/filtering-dropdown-lists-in-the-django-admin
- http://stackoverflow.com/questions/991926/custom-filter-in-django-admin
- http://stackoverflow.com/questions/3219576/django-attaching-additional-information-to-form-fields
- http://charlesleifer.com/blog/writing-custom-field-django/
- http://groups.google.com/group/south-users/browse_thread/thread/888413f195acd9c2/0ee513da38240e19
- http://blueprintforge.com/blog/2012/01/24/measuring-optimising-database-performance-in-django/
- authentication for serving static files
- https://code.djangoproject.com/wiki/RowLevelPermissions
- http://dabapps.com/blog/logging-sql-queries-django-13/
- http://gun.io/blog/fast-as-fuck-django-part-1-using-a-profiler/
- http://andrewingram.net/2012/dec/common-pitfalls-django-south/
- http://www.ianlewis.org/en/reversing-django-admin-urls
- http://www.mahner.org/posts/separating-staff-and-user-accounts-in-djangos-admin/
- http://stackoverflow.com/questions/1206903/how-do-i-require-an-inline-in-the-django-admin
- http://stackoverflow.com/questions/3126098/conditional-inline-in-django-admin
- http://lincolnloop.com/blog/2010/dec/16/using-proxy-models-customize-django-admin/
- http://www.rlazo.org/2008/10/24/documenting-a-django-project-with-sphinx/
- http://www.apreche.net/complete-single-server-django-stack-tutorial/
- https://www.xormedia.com/high-performance-web-reducing-database-round-trips/
- http://bruno.im/2013/may/18/django-stop-writing-settings-files/
- http://stackful-dev.com/django-email-tricks-part-1.html
- http://blog.disqus.com/post/62187806135/scaling-django-to-8-billion-page-views
- http://opensourcehacker.com/2013/10/16/accepting-and-spending-bitcoins-in-a-django-application/
- https://www.digitalocean.com/community/articles/how-to-scale-django-finding-the-bottleneck
- https://syerram.silvrback.com/make-django-fasssst
- http://blog.kevinastone.com/django-model-descriptors.html
- https://engineering.betterworks.com/2015/09/03/sqlalchemy-and-django/
- http://andrewsforge.com/article/upgrading-django-to-17/part-3-django-17-new-features/#system-check-framework
There a subtle bug for the required property in a
MultiValueField
class IndirizzoField(forms.MultiValueField):
def __init__(self, **kwargs):
fields = (
forms.CharField(required=False, initial=''),
forms.CharField(required=False, initial=''),
forms.CharField(required=False, initial=''),
forms.CharField(required=False, initial=''),
forms.CharField(required=False, initial=''),
forms.CharField(required=False, initial=''),
)
self.was_required = kwargs.get('required', True)
kwargs['required'] = False
super(IndirizzoField, self).__init__(fields, **kwargs)
def compress(self, data_list):
if self.was_required and len(data_list) == 0:
raise forms.ValidationError("Inserisci almeno un valore")
return '$'.join(data_list)
class IndirizzoWidget(forms.MultiWidget):
def __init__(self, attrs=None):
self.count = 6
self.labels = (
'Via',
'N',
'CAP',
'Comune',
'Provincia',
'Nazione',
)
widgets = (
forms.TextInput(),
) * self.count
super(IndirizzoWidget, self).__init__(widgets, attrs)
def decompress(self, value):
if not value:
return [None, None, None, None, None,]
return value.split('$')
def format_output(self, rendered_widgets):
widgets = []
for label, widget in zip(self.labels, rendered_widgets):
widgets.append(u'<b>%s</b> %s' % (label, widget))
return ''.join(widgets)
import zipfile
import StringIO
def _make_ods(self, request, queryset):
ods_name = os.path.abspath(os.path.dirname(__file__) + '/ods/template.ods')
if len(queryset) > 1:
self.message_user(request, "Please choose only one")
# FIXME: I don't know if is correct to return
# without a response
return
# http://djangosnippets.org/snippets/15/
"""
odf_path - path to the template document
context - dictionary to create context from
"""
ordine = queryset[0]
# per evitare che mi crei doppioni utilizzo un set() per le destinazioni dei materiali
depositi = ordine.destinazione
c = Context({
"ordine": ordine,
"depositi": depositi,
})
# default mimetype
mimetype = 'application/vnd.oasis.opendocument.text'
# ODF is just a zipfile
input = zipfile.ZipFile(ods_name, "r" )
# we cannot write directly to HttpResponse, so use StringIO
text = StringIO.StringIO()
# output document
output = zipfile.ZipFile(text, "a")
# go through the files in source
for zi in input.filelist:
out = input.read(zi.filename)
# waut for the only interesting file
if zi.filename == 'content.xml':
# un-escape the quotes (in filters etc.)
t = Template(out)
# render the document
out = t.render(c)
elif zi.filename == 'mimetype':
# mimetype is stored within the ODF
mimetype = out
output.writestr(zi.filename, smart_str(out))
# close and finish
output.close()
response = HttpResponse(content=text.getvalue(), mimetype=mimetype)
response['Content-Disposition'] = 'attachment; filename=ordine-acquisto.ods'
return response
# aptitude -PV install libpq-dev
(env) $ pip install psycopg2
If you tryied to drop the tables but dependencies errors pops out try this
# drop table app_model cascade;
# apt-get install libmysqlclient-dev
$ pip install MySQL-python
In order to support transactions you need to use InnoDB engine
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'apidb',
'USER': 'root',
'PASSWORD': 'password',
'OPTIONS': {
'init_command': 'SET storage_engine=INNODB',
}
}
- Add ability to store only relative paths in a FilePathField
- Django's model doesn't call full_clean(): SO question ticket package