Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Another strange django unicode error solved!
Today while trying to my final product to one of our customer's an ugly little error shot back at me when I tried editting any of the imported records into the database. "django ascii codec can't encode ..." bla bla it would complain and refuses to render the said template. Tracking down the problem down, I found it to the __str__ method being returned one of my models. After changing the database encoding for my MySQL database ( sucky on windoze ), it still stubbornly spat back the same error at me. Finally after searching around more I found the smart_str method's usage here. Kudos! It works now. So instead of returning the normal 'str(self.name)' I do a 'smart_str(self.name)' and everything is back to it's hunky doriness! -
ifequal
More late-nite hacking. Tonight I needed this little nugget: class IfEqualNode(Node): def __init__(self, var1, var2, nodelist_true, nodelist_false, negate, parser=None): self.var1, self.var2 = Variable(var1), Variable(var2) self.nodelist_true, self.nodelist_false = nodelist_true, nodelist_false self.negate = negate self.parser = parser def __repr__(self): return "<" + "IfEqualNode>" def render(self, context): try: val1 = self.var1.resolve(context) except VariableDoesNotExist: val1 = None # crazy ghf patch filter_expression = self.parser.compile_filter(self.var1.var) vn1 = self.parser.create_variable_node(filter_expression) val1 = vn1.render( context ) try: val2 = self.var2.resolve(context) except VariableDoesNotExist: val2 = None # crazy ghf patch filter_expression = self.parser.compile_filter(self.var2.var) vn2 = self.parser.create_variable_node(filter_expression) val2 = vn2.render( context ) if (self.negate and val1 != val2) or (not self.negate and val1 == val2): return self.nodelist_true.render(context) return self.nodelist_false.render(context) def do_ifequal(parser, token, negate): bits = list(token.split_contents()) if len(bits) != 3: raise TemplateSyntaxError, "%r takes two arguments" % bits[0] end_tag = 'end' + bits[0] nodelist_true = parser.parse(('else', end_tag)) token = parser.next_token() if token.contents == 'else': nodelist_false = parser.parse((end_tag,)) parser.delete_first_token() else: nodelist_false = NodeList() return IfEqualNode(bits[1], bits[2], nodelist_true, nodelist_false, negate, parser) def ifequal(parser, token): """ Outputs the contents of the block if the two arguments equal each other. Examples:: {% ifequal user.id comment.user_id %} ... {% endifequal %} {% ifnotequal user.id comment.user_id %} ... {% else %} ... {% endifnotequal %} """ … -
Django i18n status
Here you have what, from my point of view, is the status of django i18n. Comments will be very welcome, specially from people from countries with other i18n needs than mine (based on the idea that Django i18n is perfect for people in the US, here is the troubleshooting for my country, for sure more problems exists for people in for example China).This list is part of the analysis that I'm doing to fix all those problems. If you want to participate in making Django also "The web framework for perfectionists outside the US", please contact me.SubjectCommentsTranslation (static content)YesDjango has an amazing translation system, easy to use, and exceptionally automated. Also it has bidi support. Despite of this, some problems can be found when translating django or applications to other languages (masculine/femenine...).Translation (database content)NoDjango doesn't support model field translation, but it can be achieved using an external application such as TransDb, django-multilingual, django-utils translation service and i18ndynamic. As far as I know only TransDb and django-multilingual are working on Django's trunk.Calendar customizationNoPatching Django is required to change first day of week in admin calendar (first day of week is Monday according to ISO and in many countries (most Europe, most … -
Documenting Django pluggable apps with Sphinx
I decided to document my Django projects with the same tool used by Django team: Sphinx. It is a very good documenting tool, and was used for many other projects, including the Python Project itself. But it has a simple problem with Django, that I found the solution rlazo’s blog. But it still has some [...] -
Novos pacotes relacionados ao django no debian
Segundo notícia publicada por Daniel Watkins em seu blog, novos pacotes de aplicativos Django foram adicionados ao Debian, entre eles: django-tinymce, fornece o widget TinyMCE para uso em forms e em views django-filebrowser, que adiciona uma interface para gerenciamento de arquivos dentro do próprio admin do django. django-contact-form, que como o próprio nome já diz, provê uma forma fácil de criar formulários de contato. Por enquanto, os pacotes estão disponíveis apenas no Debian Unstable. -
Selecting Web Hosting
I've been interested in finding out what it takes to attract traffic to a site and what type of money it draws in with Google's Adsense program. So along with building a website I'm also going to learn python and django to develop the site. So recently I've been spending some of my free time going through django tutorials and writing small applications to get the hang of python. I've also discovered not to enter python into a browser and push ctrl-enter at work because python.com is very different from python.org. What I found while performing the initial implementation and developing a basic blogging application is that it's not the python and django programming where I ran into most of the problems rather all of the setup of apache, the database, finding web hosting, etc. The following is going to be talking about my experience searching for a good host for my django applications. My initial criteria when selecting a company to provide hosting is first to be inexpensive. This criteria was key since I'll be primarily using the hosting for a blog and any experimentation so I didn't want to start dumping buckets of money into this project. Along … -
Еще один
isagalaev@isagalaev:~$ curl -is http://afisha.yandex.ru/ | grep Server: Server: lighttpd / Pony Powered! Вот! Подробности позже. И, наверное, даже не у меня... -
Еще один
isagalaev@isagalaev:~$ curl -is http://afisha.yandex.ru/ | grep Server: Server: lighttpd / Pony Powered! Вот! Подробности позже. И, наверное, даже не у меня... -
Google Moderator for PyCon ORM Panel
I'm going to be moderating a panel this year at PyCon between 5 of the Python ORMs(Django, SQLAlchemy, SQLObject, Google App Engine, and web2py). To make my job easier, and to make sure the most interesting questions are asked I've setup a Google Moderator page for the panel here. Go ahead and submit your questions, and moderate others to try to ensure we get the best questions possible, even if you can't make it to PyCon(there will be a recording made I believe). I'll be adding my own questions shortly to make sure they are as interesting as I think they are.Also, if you aren't already, do try to make it out to PyCon, there's still time and the talks look to be really exceptional. -
New Django Site: Brite Revolution
Josh Kersey announced tonight a new site built by the folks at Cabedge and it appears to be done in Django. I love seeing fresh ideas, especially concerning digital media. I have long thought the music industry just doesn't get the last 5 to 10 years of technological innovation and public mood shift. Now, I am not industry expert, but I don't think it takes a wizard to see that Apple has single handedly been disruptive in this area. Couple that with the ability for individuals to produce very high quality recordings in their basement cheaply and then leverage social media and the Internet to distribute their music. The game has changed. Brite Revolution is the first thing I have seen that is formerly recognizing that and building a business model around it. From their About page: Artists need to be able to make music again without going into debt or losing ownership of their music. Fans need more music from their favorite artists on a regular basis and feel like a part of an event again. Philanthropic organizations need more opportunities to connect directly with people to make a difference in the world. To top it all off, they … -
New Django Site: Brite Revolution
Josh Kersey announced tonight a new site built by the folks at Cabedge and it appears to be done in Django. I love seeing fresh ideas, especially concerning digital media. I have long thought the music industry just doesn't get the last 5 to 10 years of technological innovation and public mood shift. Now, I am not industry expert, but I don't think it takes a wizard to see that Apple has single handedly been disruptive in this area. Couple that with the ability for individuals to produce very high quality recordings in their basement cheaply and then leverage social media and the Internet to distribute their music. The game has changed. Brite Revolution is the first thing I have seen that is formerly recognizing that and building a business model around it. From their About page: Artists need to be able to make music again without going into debt or losing ownership of their music. Fans need more music from their favorite artists on a regular basis and feel like a part of an event again. Philanthropic organizations need more opportunities to connect directly with people to make a difference in the world. To top it all off, they … -
Join us a djangopeople.net!
Hey, I just stumbled upon a nice “social” site called djangopeople.net. It’s a site listing people who use Django, along with some interesting contact information. As the site says (when i signed up): Django People lists 4116 Django developers from around the world, in 110 different countries. The aim of the site is to help Django developers find like-minded souls near them, and hopefully kick-start some local meet-ups and user groups. Come us and join the party! -
The low-down on Django-Techblog
I figured I would write-up some of the features of Django Techblog, the blogging application I wrote to power this site. It does most of what you would expect from a blogging app, but there are a few features that it does differently. The main difference is extended markup, but there are a couple of other features that worthy of note: Multi-blog capable. I want to blog on a variety of subjects, but because some of the things I post about (namely the geeky stuff) are only of interest to a select few, I risk turning away visitors who aren't interested in those techy posts. Categories and tags are one solution to this, but I prefer to have a number of blogs under an umbrella blog, each with its own posts, templates and tags. In Techblog, there is also a concept of a channel which appears exactly like a blog from the front-end, but aggregates posts & tags from one or more blogs. In this site, the home-page at / is actually a channel consisting of /blog/tech/ and /blog/personal.Microblogging. Techblog has support for Twitter and potentially other microblogging services could be added. You add your twitter account details, which Techblog … -
The low-down on Django-Techblog
I figured I would write-up some of the features of Django Techblog, the blogging application I wrote to power this site. It does most of what you would expect from a blogging app, but there are a few features that it does differently. The main difference is extended markup, but there are a couple of other features that worthy of note: Multi-blog capable. I want to blog on a variety of subjects, but because some of the things I post about (namely the geeky stuff) are only of interest to a select few, I risk turning away visitors who aren't interested in those techy posts. Categories and tags are one solution to this, but I prefer to have a number of blogs under an umbrella blog, each with its own posts, templates and tags. In Techblog, there is also a concept of a channel which appears exactly like a blog from the front-end, but aggregates posts & tags from one or more blogs. In this site, the home-page at / is actually a channel consisting of /blog/tech/ and /blog/personal.Microblogging. Techblog has support for Twitter and potentially other microblogging services could be added. You add your twitter account details, which Techblog … -
Werkzeug and reverse urls
Werkzeug and reverse urls -
Django Applications at Work
Today someone at my work just released a simple Django app, the second one now running at my company. Here are the two Django apps running so far: Server scanner This is the first Django application that we use. It started out as a script that would scan all the computers on our network and determine what version of our software they were running by inspecting a special file in one of the publicly available SMB shares. The script took about half an hour to run and generated static html that was then served up by Apache. This became cumbersome for a number of reasons. For one, it took about an hour to scan the entire network. There was no persistence whatsoever so my script had no memory of which servers had our software installed on it. These servers are quick to check. The ones that are slow to check are the ones that are actually no longer on the network, or do not have the publicly available share that we are expecting. When the project manager emailed me one day and said "the servers on this page are often out of date" I sprung in to action and converted … -
Painless Amazon EC2 Backup
The past year on Amazon EC2 has taught me many things but first and foremost is back up consistently. I’ll say it again, back up consistently! Amazon even makes the backup almost painless, almost… Amazon has EC2 (the compute cloud) and S3 (the data repository). Out of the box you can back up from [...] -
Getting client OS in Django
Some times it can be useful to serve our site content with little differences depending on the visitor operating system. I really think it's a bad idea changing the content or doing some big changes, depending on it, but this post can be useful for it as well.So, while most time just some Javascript is used to customize user experience based on its operating system, few times it'll also be useful to do it in the server side.For those cases, here you've a simple context processor that will make available a template variable named "platform" which content can be "Linux", "Mac" or "Windows".import redef user_agent(request): ''' Context processor for Django that provides operating system information base on HTTP user agent. A user agent looks like (line break added): "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) \ Gecko/2009020409 Iceweasel/3.0.6 (Debian-3.0.6-1)" ''' print 'user_agent' # Mozilla/5.0 regex = '(?P<application_name>\w+)/(?P<application_version>[\d\.]+)' regex += ' \(' # X11 regex += '(?P<compatibility_flag>\w+)' regex += '; ' # U regex += '(?P<version_token>[\w .]+)' regex += '; ' # Linux i686 regex += '(?P<platform_token>[\w .]+)' # anything else regex += '; .*' user_agent = request.META['HTTP_USER_AGENT'] result = re.match(regex, user_agent) if result: result_dict = result.groupdict() full_platform = result_dict['platform_token'] platform_values … -
Updating CouchDB Views In Django
CouchDB views are a bit like stored procedures in a traditional database system. As with stored procedures it’s difficult to keep them in sync with your code, and to keep them in your version control system. In this article I’ll show you how you can use a django management command to update your views from [...] -
New CSS
I never thought that my personal blog would be useful to anyone except myself. I've not put a lot of effort into attracting traffic, but it's been trickling my way. I never really finished the templates and CSS for programmerq.net, so I spent a little time here and there over the past few days and added some CSS, and updated the templates to make the blog experience a bit nicer. I haven't added the template tags to turn on the calendar view in the sidebar, but I don't know how useful it would be anyway. I really enjoy the Django templating language. I was able to add the gravitar functionality to the comment system without modifying the source of the blog app that I use. All I did was create an app that had the template tag snippet, and a template for rendering. To get the gravitar to show up, I just copied the default comment rendering template out of the blog app, and told it to load the template tag and render in the appropriate place. As always, every site is under construction, and this site isn't an exception. I'm willing to take suggestions for improvement on my blog, … -
My Django-Compress Tasks
I am thoroughly impressed by django-compress as mentioned in yesterday's post. There are number of things that I'll be looking to add over the next couple of days that hopefully will make it even more useful for more than just me. I'll be committing these to my fork and submitting pull requests upstream to hopefully have them committing into the main repository. For output files, create the intermediary folders if they don't exist. Add a gzip option flag to the command to create gzip versions of the output files. Add a new css filter for replacing url() property contents with prefixes defined in configuration (allowing for the serving of content locally during development, and then off of CDN servers when deployed). Add a new version strategy, that will default to a prefix folder using today's timestamp (YYYYMMDD). Also allow for an optional parameter to the command line to override this default prefix. Add another "extra_context" variable called ABSOLUTE_URL to enable an override of both the PREFIX variable I included yesterday as well as the default MEDIA_URL. I need this so as to be able to put things like Google hosted libraries like jQuery, but also to have a quick and … -
My Django-Compress Tasks
I am thoroughly impressed by django-compress as mentioned in yesterday's post. There are number of things that I'll be looking to add over the next couple of days that hopefully will make it even more useful for more than just me. I'll be committing these to my fork and submitting pull requests upstream to hopefully have them committing into the main repository. For output files, create the intermediary folders if they don't exist. Add a gzip option flag to the command to create gzip versions of the output files. Add a new css filter for replacing url() property contents with prefixes defined in configuration (allowing for the serving of content locally during development, and then off of CDN servers when deployed). Add a new version strategy, that will default to a prefix folder using today's timestamp (YYYYMMDD). Also allow for an optional parameter to the command line to override this default prefix. Add another "extra_context" variable called ABSOLUTE_URL to enable an override of both the PREFIX variable I included yesterday as well as the default MEDIA_URL. I need this so as to be able to put things like Google hosted libraries like jQuery, but also to have a quick and … -
Convenciones de proyecto en Django
Django ofrece una flexibilidad muy grande a la hora de configurar nuestros proyectos permitiéndonos organizarlos con estructuras muy diversas. Esta flexibilidad permite que podamos adaptar Django a necesidades concretas pero por otro lado hace que mucha gente se pregunte cuál es la manera correcta de organizar la estructura de sus proyectos. Convenciones en Django, creado por Eric Holscher, pretende ser un punto de referencia sobre las mejores prácticas y convenciones en Django. Esto es una traducción al español de las convenciones sobre proyectos. -
Slughifi: slugs a prueba de caracteres internacionales
Slughifi es un código que mejora las características de la función slugify de django.template.defaultfilters. Soporta muchos más caracteres internacionales con todo tipo de acentuación. Mientras que slugify elimina todos estos caracteres al generar el slug, slughifi los reemplaza por caracteres no acentuados haciendo honor a su nombre al proporcionar slugs altamente fieles a la cadena sobre la que se aplica. Fue presentado hace bastante tiempo en este hilo de la lista de correo django-users y dí con él por casualidad. Desde entonces no he dejado de utilizarlo en mis proyectos. Slughifi parece no estar disponible en la página original en la que se encontraba. Sin embargo sí lo está en el trac de django-fr y también lo podéis bajar directamente desde aquí. -
django-multilingual syntax poll
Those days there is some activity in the django model translation area, specially for the two new projects that joined django-multilingual and transdb to achieve this: django-transmeta and django-modeltranslation.While there are some intentional differences among some projects (for example django-modeltranslation is the only one that can translate models without editing them), it would be great to merge all (or most) existing projects, and join the efforts to get our best application (and hopefully it'll worth to be included in Django itself).So, with the merge of those applications in mind, we're planning to create a branch on django-multilingual that will have the very best of each existing application, and any other cool idea.So if you have good Python/Django skills, and want to add some open source work in your CV... ;) join us now!Or if you are a potential user of this application, or you just think that your opinion is worth to be shared, please fill the MODEL SYNTAX POLL, or mail us with your ideas.Here there are simple sample for each option on the poll:class Translationclass MyModel(model.Model): my_field = CharField() class Translation(multilingual.Translation): my_i18n_field = CharField()custom fieldsclass MyModel(model.Model): my_field = CharField() my_i18n_field = TransCharField()separate modelclass MyModel(model.Model): my_field = CharField() my_i18n_field …