Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Peewee, a lightweight Python ORM - Original Post
Edit I rewrote peewee from the ground up. The query examples in this post are no longer supported. Edit, Jul 24, 2011: added support for Postgresql and MySQL (in addition to SQLite). Edit, June 8, 2011: added support for MySQL For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. Weighing in at about 1000 lines of code, Peewee doesn't come close to matching Django's ORM (15K LOC) in terms of API cleanliness or functionality, but it does hit many of the basic use-cases for an app that needs lightweight persistence and querying. This has definitely been one of the most rewarding projects I've worked on! Benchmarks In terms of speed, peewee is generally 25% faster than django when … -
Peewee, a lightweight Python ORM - Original Post
Edit I rewrote peewee from the ground up. The query examples in this post are no longer supported. Edit, Jul 24, 2011: added support for Postgresql and MySQL (in addition to SQLite). Edit, June 8, 2011: added support for MySQL For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. Weighing in at about 1000 lines of code, Peewee doesn't come close to matching Django's ORM (15K LOC) in terms of API cleanliness or functionality, but it does hit many of the basic use-cases for an app that needs lightweight persistence and querying. This has definitely been one of the most rewarding projects I've worked on! Benchmarks In terms of speed, peewee is generally 25% faster than django when … -
jquerymobile and having design constraints
I’ve been working on this idea/project called Eyes for the past year on and off. Maybe for the past 4 to 6 months I’ve been stymied by what I want the visual representation to look like, struggling with the options … Continue reading → -
Askani crea los modelos de tu aplicación gráficamente
Askani es una interfaz gráfica para generar modelos de Django. Álvaro Mouriño nos cuenta que lleva trabajando algo más de un mes en este proyecto. Askani está desarrollado en javascript y permite definir de forma gráfica modelos, campos, métodos y opciones meta en un estilo bastante similar a UML. Resulta útil para tener una representación más gráfica de los modelos y generar su código automáticamente. -
Django South in a team using SVN
South, the schema and data migration tool for django is really useful. I’ve only started using it myself recently but the benefit is immediate. South creates python files which hold all the information for migrations each time you change the database schema. Each person in a team of developers needs to run these migrations on [...] -
Django South in a team using SVN
South, the schema and data migration tool for django is really useful. I’ve only started using it myself recently but the benefit is immediate. South creates python files which hold all the information for migrations each time you change the database schema. Each person in a team of developers needs to run these migrations on their development database to keep things up to date and working. The question is how does one person in a team know that another has changed the schema? If time has passed then simply asking could get a somewhat hazy response. We use SVN to keep track of code changes amongst the team of developers. SVN is a good place to look to see if migrations were committed. The only thing better than looking in SVN logs for migrations is for SVN to tell us when migrations are committed. So that is what I’ve had a go at doing. Using the SVN pre-commit hook I’ve been able to send emails to those involved in a project each time someone commits code that contains new database migration changes. The first part of this was to create a pre-commit.bat file in the hooks directory of my projects … -
HTML5 offline manifests with django-mediagenerator
This is actually part 3 of our django-mediagenerator Python canvas app series (see part 1 and part 2), but since it has nothing to do with client-side Python we name it differently. In this part you'll see how to make your web app load without an Internet connection. HTML5 supports offline web apps through manifest files. Manifest files First here's some background, so you know what a manifest file is. A manifest file is really simple. In its most basic form it lists the URLs of the files that should be cached. Here's an example.manifest: CACHE MANIFEST /media/main.css /media/main.js The first line is always CACHE MANIFEST. The next lines can list the files that should be cached. In this case we've added the main.css and main.js bundles. Additionally, the main HTML file which includes the manifest is cached, automatically. You can include the manifest in the <html> tag: <html manifest="example.manifest"> When the browser sees this it loads the manifest and adds the current HTML and manifest file and all files listed in the manifest to the cache. The next time you visit the page the browser will try to load the manifest file from your server and compare it to … -
App-Centric Django Development Part 1: Introduction
We’ve created many web sites at The Washington Times, many were just speculative, and most are not around today. In order to prototype a web site quickly, we developed a set of habits that make it easier. I call it “app-centric Django development”. Projects and Apps Django projects and apps are codependent. As a result, most developers write monolithic projects that contain all their apps. It’s easy to do and to understand, but it is not easy for reusing your code. I had a 500-in-1 Electronics set from Radio Shack when I was a kid. I loved it because I could easily create a new device or test different modifications easily. That’s what a Django project is, to me: tt is a place for wiring all the components together. Apps are the individual components; the diodes, transistors, integrated circuits and light bulbs. Our prototyping framework, Calloway, is the direct result of this methodology. The project consists of templates, settings and configuring how different applications work together, and the apps are completely separate. A project may have a few very specific apps that just don’t make sense outside of the web site’s scope, but the vast majority of the apps are installed using pip. Isn’t it … -
Introductory Python Programming Sessions in Kuwait
KBSoft will be conducting a series of introductory sessions designed to introduce programmers to new programming tools and to help improve their programming skills. The sessions are: Sunday, Nov 21st 2010 7pm — 9pm: An Introduction to Revision Control with Git. The goal of this session is to introduce how revision control systems can be an indispensable tool to programmers. Git will be the tool of choice for this session and we will go through a number of exercises to show how useful it can be to both individual programmers and programming teams. We will also be introducing a number of best practices for using using Git and help the attendees get more familiar with the system. Tuesday, Nov 23rd 2010 7pm — 9pm: An Introduction to the Python Programming Language. The goal of this session is to introduce python as a general purpose programming language that can be used to solve most problems faced by programmers in Kuwait. There will be a number of exercises to introduce the language syntax and features. In addition to an overview of some of the useful packages in the standard library, language best practices, and how to setup a functional development environment. Thursday, Nov 25th 2010 7pm — … -
Class Based Views and Dry Ravioli
Class based views are very cool. I am starting to clean up an existing project using them, and lots of existing views are turning into declarative code. But it makes me worried about the ravioli effect. -
Django deployment problem
Actually, there are several problems:Upload to the server - usually solved via SCM like git, mercurial, subversion etc – SolvedCopy application files to proper destinations, reboot application - bash/fabric etc. – SolvedCopy user-related media files – usually solved via ignore files, symlinks etc. but there is NO STANDARD or SOLUTION - UnsolvedMigrate database, maybe it's possible to solve it via some migration tool like South but actually I don't know and at this point it's still - UnsolvedFallback to previous version (=any version?) – unsolved and almost impossible to keep data in actual state trough migrations - Unsolved So, what I think about it.Database MigrationsI guess it's possible to solve via South. Another way is to write my own migrations with specific format - SQL with bash/python etc. I will dedicate some time to learn more about migration.Copy user-related media filesI saw something about it in latest version of django. But sometimes I have to work with old releases (1.1.1) of django I need to keep it independent from django - I'll create configuration file which will consist from list of directories where User's data will be stored. Then some playing with symlinks and it will be solved.And, at leastFallback to previous versionThere … -
How to handle variations with Javascript within Satchmo's product template
My goal was to list a set of variations on product page and redirect user to related product page if variation was changed. For example we have two variations:SizeColourAnd values of variatons:Colour: red, black, whiteSize: M (middle), L (large), S (small)So, first of all I display this variations on product page and when user change something (colour or size) then redirect to product with selected colour and size respectively.1. Show dropdowns with variations:{% for option_group in options %}{% trans "Select" %}{{ option_group.name }}{% for choice in option_group.items %} {{ choice.translated_name }}{% if choice.price_change %}{% option_price choice %}{% endif %}{% endfor %}{% endfor %}2. Store all possible variations for javascript to find related product if some of variations was changed on the page:// list of available variations of current product var variations = [ {% for product_variation in product.configurableproduct.productvariation_set.all %}{ 'url': '{{ product_variation.product.get_absolute_url }}', {% for option in product_variation.options.all %} 'group-{{ option.option_group.id }}': '{{ option.value }}'{% if not forloop.last %},{% endif %} {% endfor %} }{% if not forloop.last %},{% endif %}{% endfor %}];3. Add JavaScript code which will handle variations changes: /** * Select & go to variation which have been selected via select box. * This functionality require a … -
Offline HTML5 canvas app in Python with django-mediagenerator, Part 2: Drawing
In part 1 of this series we've seen how to use Python/pyjs with django-mediagenerator. In this part we'll build a ridiculously simple HTML5 canvas drawing app in Python which can run on the iPad, iPhone, and a desktop browser. Why ridiculously simple? There are a few details you have to keep in mind when writing such an app and I don't want these details to be buried under lots of unrelated code. So, in the end you will be able to draw on a full-screen canvas, but you won't be able to select a different pen color or an eraser tool, for example. These extras are easy to add even for a newbie, so feel free to download the code and make it prettier. It's a nice exercise. Reset the viewport With a desktop browser we could start hacking right away, but since we also support mobile browsers we need to fix something, first: One problem you face with mobile browsers is that the actual screen size is not necessarily the same as the reported screen size. In order to work with the real values we have to reset the viewport in the <head> section of our template: <head> <meta … -
bpssl - The Django SSL Support Application
bpssl - The Django SSL Support Application -
Quelques nouveautés de django 1.3
Comme l'indique la roadmap officielle, django 1.3 c'est pour dans bientôt. La bêta avec freeze des fonctionnalités, c'est pour dans 15 jours et la release, pour le 17 janvier. Tout bientôt donc. Il a de plus déjà été annoncé qu'il n'y aurait pas de nouvelles fonctionnalités dans cette version, que ce serait surtout une release ... -
Django with virtualenv on Webfaction
I really like the Django web framework and I like virtualenv enabling me to use different python configs and packages for different projects. And I have to say I like Webfaction, so easy, so good! (No, I don't get paid by them) This is a quick guide on how to setup Django in virtualenv using mod_wsgi with a Webfaction account. Create an "mod_wsgi" application and create a website to use this application connect to your accounts shell using ssh enable Python 2.6.x as default python (as written in the Webfaction documentation) run "vi ~/.bash_profile" append the line "alias python=python2.6" (navigate to the last line, push "i" for insertion, write the line, push escape) save the file and exit (enter ":wq") reload the bash profile "source ~/.bash_profile" ensure it worked by checking the Python version "python -V" install "pip" and "virtualenv" (be sure to use easy_install-2.6 to use the setuptools of Python 2.6.x): enter "easy_install-2.6 -U pip" enter "easy_install-2.6 -U virtualenv" I like yolk, that enables you to list the installed Python packages, install it using pip if you like "pip install yolk" Note that these packages (pip, virtualenv, yolk) are installed in your global Python. I recommend to not install … -
Django with virtualenv on Webfaction
I really like the Django web framework and I like virtualenv enabling me to use different python configs and packages for different projects. And I have to say I like Webfaction, so easy, so good! (No, I don't get paid by them) This is a quick guide on how to setup Django in virtualenv using mod_wsgi with a Webfaction account. Create an "mod_wsgi" application and create a website to use this application connect to your accounts shell using ssh enable Python 2.6.x as default Python interpreter (as written in the Webfaction documentation) echo "alias python=python2.6" >> ~/.bash_profile source ~/.bash_profile python -V install "pip" and "virtualenv" (be sure to use easy_install-2.6 to use the setuptools of Python 2.6.x): easy_install-2.6 -U pip easy_install-2.6 -U virtualenv I like yolk, that enables you to list the installed Python packages, install it using pip if you like pip install yolk Note that these packages (pip, virtualenv, yolk) are installed in your global Python. I recommend to not install any more packages to the global installation as virtualenv enables use to install all packages we need into the virtualenv Python lib. navigate to your recently create mod_wsgi webapp, there should be 2 folders, "apache2" and "htdocs" … -
Django with virtualenv on Webfaction
I really like the Django web framework and I like virtualenv enabling me to use different python configs and packages for different projects. And I have to say I like Webfaction, so easy, so good! (No, I don't get paid by them) This is a quick guide on how to setup Django in virtualenv using mod_wsgi with a Webfaction account. Create an "mod_wsgi" application and create a website to use this application connect to your accounts shell using ssh enable Python 2.6.x as default Python interpreter (as written in the Webfaction documentation) echo "alias python=python2.6" >> ~/.bash_profile source ~/.bash_profile python -V install "pip" and "virtualenv" (be sure to use easy_install-2.6 to use the setuptools of Python 2.6.x): easy_install-2.6 -U pip easy_install-2.6 -U virtualenv I like yolk, that enables you to list the installed Python packages, install it using pip if you like pip install yolk Note that these packages (pip, virtualenv, yolk) are installed in your global Python. I recommend to not install any more packages to the global installation as virtualenv enables use to install all packages we need into the virtualenv Python lib. navigate to your recently create mod_wsgi webapp, there should be 2 folders, "apache2" and "htdocs" … -
Django with virtualenv on Webfaction
I really like the Django web framework and I like virtualenv enabling me to use different python configs and packages for different projects. And I have to say I like Webfaction, so easy, so good! (No, I don't get paid by them) This is a quick guide on how to setup Django in virtualenv using mod_wsgi with a Webfaction account. Create an "mod_wsgi" application and create a website to use this application connect to your accounts shell using ssh enable Python 2.6.x as default Python interpreter (as written in the Webfaction documentation) echo "alias python=python2.6" >> ~/.bash_profile source ~/.bash_profile python -V install "pip" and "virtualenv" (be sure to use easy_install-2.6 to use the setuptools of Python 2.6.x): easy_install-2.6 -U pip easy_install-2.6 -U virtualenv I like yolk, that enables you to list the installed Python packages, install it using pip if you like pip install yolk Note that these packages (pip, virtualenv, yolk) are installed in your global Python. I recommend to not install any more packages to the global installation as virtualenv enables use to install all packages we need into the virtualenv Python lib. navigate to your recently create mod_wsgi webapp, there should be 2 folders, "apache2" and "htdocs" … -
Livro Python e Django – Resenha
Finalizei a leitura do livro Python e Django — Desenvolvimento ágil de aplicações web, escrito pelo Osvaldo Santana. Estamos carentes de bons livros sobre Python e Django em português e o Osvaldo soube preencher bem essa lacuna com um material de excelente qualidade, tanto para aqueles que querem aprender quanto para quem já trabalha com Python e Django. Recebi o livro a algumas semanas, mas fiz questão de ler com bastante atenção antes de escrever essa resenha. Para quem está procurando um ótimo material em português, o livro começa explicando o básico de Python, funções, bultins, módulos, classes e orientação a objetos. As explicações de cada item são curtas e recheadas de exemplos, ideal para quem não quer perder tempo com muita teoria e quer aprender na prática, mas com as explicações teóricas na dose certa. A partir do capítulo 5 o livro entra na parte de programação, com exemplos e dicas interessantes. O capítulo 6 explica sobre orientação a objetos, em uma linguagem didática e direta ao ponto. No capítulo 8, o Django é apresentado, assim como uma boa explicação sobre o paradigma MVC. Logo em seguida vem a modelagem de dados, templates, formulários e segurança. Todo conteúdo teórico … -
Introducció a Celery
Introducció a Celery Celery es una aplicació que ens permet crear tasques de feina asíncrones gestionades per un gestor de cues que està basada en l'enviament de missatges de manera distribuïda. Es focalitza en operacions en temps real però també suporta la calendarització de tasques. Les unitats d'execució, anomenades tasques, s'executen de manera concurrent en un o més nodes de treball. Aquestes tasques poden executar-se de manera asíncrona bé de manera síncrona (esperant fins que la tasca està llesta). El sistema de missatgeria recomanat per celery és RabbitMQ encara que és bastant agnòstic en el tema i pot fer servir com a substitut Redis, MongoDB o una base de dades sql. Encara que el programa va sorgir lligat a Django, actualment és una llibreria que es pot utilitzar de manera independent. S'han creat dos projectes a partir de l'original, Celery manté l'estructura bàsica de la llibreria i django-celery manté la integració amb Django. Bé, fins aquí la parrafada d'introducció traduïda amb més o menys fortuna de la documentació de Celery, el que estam dien és que celery ens permet executar tasques de manera distribuïda, on el director d'orquestra (si seguim les recomanacions) és una aplicació anomenada RabbitMQ, escrita en Erlang, … -
django-lastfm
On my old Wordpress blog I had a widget that let me display some of my last.fm stats. Since there was no such widget for Django powered sites (or I didn’t search well enough), I created my own as you can see in the right column. You currently can choose between your recently listened tracks, your weekly artist chart and your top artists. I’ve created a bitbucket project for its further development. So go clone it and give some feedback. PS: I’ll update/write the documentation within the next few days … ;-) -
django-lastfm
On my old Wordpress blog I had a widget that let me display some of my last.fm stats. Since there was no such widget for Django powered sites (or I didn’t search well enough), I created my own as you can see in the right column. You currently can choose between your recently listened tracks, your weekly artist chart and your top artists. I’ve created a bitbucket project for its further development. So go clone it and give some feedback. PS: I’ll update/write the documentation within the next few days … ;-) -
Django-sphinxdoc 0.2 now with documentation!
Just released version 0.2 of django-sphinxdoc. It can now display the documentation itself, the general index and the module index. The source and static views as well as the search functionality is not implemented yet. I’m still pondering whether to use a Google custom search or the Sphinx JavaScript search. Maybe it would be even better if I used Haystack … You can find a quick guide as well as some other guides in django-sphinxdoc’s documentation section (which is of course powered by django-sphinxdoc ;-)). The download can be found at bitbucket.org. -
Django-sphinxdoc 0.2 now with documentation!
Just released version 0.2 of django-sphinxdoc. It can now display the documentation itself, the general index and the module index. The source and static views as well as the search functionality is not implemented yet. I’m still pondering whether to use a Google custom search or the Sphinx JavaScript search. Maybe it would be even better if I used Haystack … You can find a quick guide as well as some other guides in django-sphinxdoc’s documentation section (which is of course powered by django-sphinxdoc ;-)). The download can be found at bitbucket.org.