Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
A Default Bug in Django
Not to say that this is a bug in django but rather a bug in how I had written some of my models. Just wanted to point out a quick tip for anyone else who may have done the same thing as me as well as for any of the django experts out there that might suggest a better way. What was happening was that I began to notice a wild discreptancy between two datetime columns in several models. They should have been identical, however, they were both getting their dates differently: ... date_column_one = models.DateTimeField(default=datetime.now()) date_column_two = models.DateTimeField(auto_now_add=True) ... What seems to be happening with this configuration is that datetime.now() is executed once when the server starts (and/or the module is imported) instead of what I thought would happen when I initially wrote these and that datetime.now() would get executed anytime an instance of the model was created and saved as a new record. My solution was to override the save method: ... date_column_one = models.DateTimeField() ... def save(self): if not self.id: self.date_column_one = datetime.now() super(MyModel, self).save() ... I am sure there is probably a better way and if you know of one, please leave a comment or send … -
A Default Bug in Django
Not to say that this is a bug in django but rather a bug in how I had written some of my models. Just wanted to point out a quick tip for anyone else who may have done the same thing as me as well as for any of the django experts out there that might suggest a better way. What was happening was that I began to notice a wild discreptancy between two datetime columns in several models. They should have been identical, however, they were both getting their dates differently: ... date_column_one = models.DateTimeField(default=datetime.now()) date_column_two = models.DateTimeField(auto_now_add=True) ... What seems to be happening with this configuration is that datetime.now() is executed once when the server starts (and/or the module is imported) instead of what I thought would happen when I initially wrote these and that datetime.now() would get executed anytime an instance of the model was created and saved as a new record. My solution was to override the save method: ... date_column_one = models.DateTimeField() ... def save(self): if not self.id: self.date_column_one = datetime.now() super(MyModel, self).save() ... I am sure there is probably a better way and if you know of one, please leave a comment or send … -
A Default Bug in Django
Not to say that this is a bug in django but rather a bug in how I had written some of my models. Just wanted to point out a quick tip for anyone else who may have done the same thing as me as well as for any of the django experts out there that might suggest a better way. What was happening was that I began to notice a wild discreptancy between two datetime columns in several models. They should have been identical, however, they were both getting their dates differently: ... date_column_one = models.DateTimeField(default=datetime.now()) date_column_two = models.DateTimeField(auto_now_add=True) ... What seems to be happening with this configuration is that datetime.now() is executed once when the server starts (and/or the module is imported) instead of what I thought would happen when I initially wrote these and that datetime.now() would get executed anytime an instance of the model was created and saved as a new record. My solution was to override the save method: ... date_column_one = models.DateTimeField() ... def save(self): if not self.id: self.date_column_one = datetime.now() super(MyModel, self).save() ... I am sure there is probably a better way and if you know of one, please leave a comment or send … -
Update to django-ae-utils
I’ve been hanging out at the NYC App Engine Hackathon today and I’ve had some time to work on django-ae-utils. Accordingly I’ve just posted an update to django-ae-utils. This update includes a User model which uses the App Engine datastore as a backend, as well as a few generic views for working with the model. [...] -
Extra
Después del fin de semana laaargo, en el cual me desconecte de la red y solo interactue en el "mundo real", llegué hoy a mi universidad y me di cuenta que la gente de google me envio un correo, solo para decirme que ya me habilitaron la cuenta de Google App Engine, ahora a hechar codigo!!! -
Mondrian & ReviewBoard
Word is that the a version of the code review tool that Google uses internally (called Mondrian) on the Google App Engine – called Code Review. I remember first seeing the Google tech talk on Mondrian and thinking that was … Continue reading → -
Django Templates: Good for so much more than HTML
I’m a big fan of Jon Bentley, the author of Programming Pearls. In this book, he discusses elegant solutions to problems that have irritated programmers for years. (I was in Europe for 6 weeks last year, and this was the one book that remained consistently in my bag throughout the whole trip. I’m not joking.) In [...] -
DjangoSites Gets New Shoes
I launched DjangoSites publicly last June, and since then we've had over 1,250 websites submitted to what has become the ultimate directory of Django-powered websites. The look and feel of the site didn't seem to have the same zing that many of the listed sites had though, so after a quick chat with the ever-creative Martin 'maddiin' Czura he was able to put together a new design that we both think is a great improvement. The new design is already online at DjangoSites.org, with a few nifty changes as well as the colour scheme such as an improved navigation bar and less cluttered positioning of user account options. At the same time, the website has been moved to a new VPS with KnownHost. I've been using KnownHost for over a year now and their VPS hosting is fantastic. The support from them has always been helpful, and their prices are very reasonable for what has been a very reliable service. I updated the TTL for the djangosites.org domain a few weeks back, so by the time this post goes live the new IP address should be accessible to anybody with properly configured DNS servers. I encourage you to do a … -
DjangoSites Gets New Shoes
I launched DjangoSites publicly last June, and since then we've had over 1,250 websites submitted to what has become the ultimate directory of Django-powered websites. The look and feel of the site didn't seem to have the same zing that many of the listed sites had though, so after … -
Habemus Python!!!
Hace poco fue el dia D para python y django puesto que el gran hermano Google lanzó el beta de Google App Engine, un sdk de desarrollo de aplicaciones web powered by python, pues bien el ingeniero Camilo Nova, CEO de Axiacore, me pidió que lo asesorará sobre django, y lo hicé, en cuestion de 1 hora, le mostré el potencial de django y quedó sorprendido, por lo cual dijo que lo iba a pensar y hoy me dio la noticia de que AxiaStore se desarrollará en python, por lo cual puedo decir: Habemus Python!!! -
Django performance testing – a real world example
About a week ago Andrew and I launched a new Django-powered site called Hey! Wall. It’s a social site along the lines of “the wall” on social networks and gives groups of friends a place to leave messages, share photos, videos and links. We wanted to gauge performance and try some server config and code changes to see what steps we could take to improve it. We tested using httperf and doubled performance by making some optimisations. Server and Client The server is a Xen VPS from Slicehost with 256MB RAM running Debian Etch. It is located in the US Midwest. For testing, the client is a Xen VPS from Xtraordinary Hosting, located in the UK. Our normal Internet access is via ADSL which makes it difficult to make enough requests to the server. Using a well-connected VPS as the client means we can really hammer the server. Server spec caveats It’s hard to say exactly what the server specs are. The VPS has 256MB RAM and is hosted with similar VPSes, probably on a quad core server with 16GB RAM. That’s a maximum of 64 VPSes on the physical server, assuming it is full of 256MB slices. If the … -
Queryset-Refactor Merged!
Od dawna rozwijany w osobnym branchu ulepszony ORM został połączony z drzewem głównym. W końcu możemy uaktualniać wiele rekordów w tabeli na raz, czy też korzystać z dziedziczenia modeli. Jedyne niekompatybilność na które natrafiłem, to OneToOneField nie jest teraz domyślnie kluczem... -
Django sites
He estado revisando sitios "powered by django" enhttp://www.djangosites.org y he encontrado http://dpaste.com/ que estacomo el mas alto por votos.pdt: este post fue escrito probando la funcionalidad de blogger de mail2blog -
quicknote
Hace poco me consegui un trabajo donde debo hacerle varios cambios a una aplicacion desarrollada en python con gtk como librera gráfica llamada quicknote, lo interesante del asunto es que corre en un celular nokia 810 que esta muy coqueto, ojala me pudiera comprar uno de estos, tienen un linux propio que es derivado de debian, por lo que tiene repositorios apt y todo eso, algunos paquetes como python ya estan portados a este dispositivo, y dentro de poco daran soporte para qt.Es muy vacano ver como las empresas de dispositivos moviles como nokia, le apuestan a linux y sobretodo a python, otra cosa interesante que alcancé a ver que tiene soporte para pygame, por lo que se pueden desarrollar juegos para este movil.Y tiene ssh!!! el mejor amigo del hombre geek!!! (frase de Santiago Ruano) -
Установка и настройка Django на "боевом" сервере с CentOS 5
Я делаю на Django Энциклопедию языков программирования. За время работы сайта выяснилось, что нужен свой выделенный сервер для большей производительности и стабильности. Пока что взял дешевый сервер с 1.8 ГГц процессором и 512 Мб памяти. В этой статье я расскажу об установке и настройке на этом сервере Django с mod_python для Apache, с кэшированием memcached и lighttpd для статических файлов. Итак, у нас есть свежеустановленная CentOS 5 и желание хостить сайт на Django (или несколько сайтов). Что для этого надо установить? Собственно Django MySQL-python mod_python memcached lighttpd Все шаги, кроме установки самого Django, — необязательные (например, можно использовать Django с fcgi вместо mod_python и PostgreSQL или другую СУБД вместо MySQL), но шаги 1-3 – то, что вы скорее всего будете использовать, а 4-5 – для повышения производительности. Статья, в основном, CentOS-ориентированная, но в определенной степени подойдет и для других дистрибутивов Linux. Замечание по безопасности: так как это свежеустановленная система, я не боюсь сломать что-то уже работающее, так что могу работать под правами root. Но лучше, конечно, работать под правами непривилегированного пользователя, и использовать “sudo” для команд, требующих административные привилегии. Ну, начнем. Собственно Django В большинстве случаев стоит устанавливать самую свежую svn-версию Django, а не “релиз”. На сегодняшний момент, “официальный релиз” слишком устарел, и в нем отсутствует множество полезных возможностей … -
Introducing django-ae-utils
Recently I’ve started to play around with using Django on Google’s new App Engine. As mentioned by many others at this point, Django technically runs on App Engine but there are significant parts which do not. Accordingly I’ve started to write some code to replace or supplement the holes left in Django by App Engine. [...] -
Google App Engine on Win2K (using django-yui-layout-templates)
Update : September 1, 2008 I guess Googs finally caught on as their 1.1.2 installer works on Win2K! FTW! Update After finally getting time to play around with the Google App Engine Django helpers, here’s a few more steps to integrate nicely with the helper suite. Move the appengine installation from C:\AppEngine\ to where the Windows installer would have installed it to: C:\Program Files\Google\google_appengine (make sure to clean up your .pyc files) Add the following to your PYTHONPATH system variable: %APPENGINE%\;%APPENGINE%\lib;%APPENGINE%\lib\yaml\lib;%APPENGINE%\lib\webob; After following the instructions, you should be good to go with Django + AppEngine! FTW! Whee. So I finally get an hour or so to play around with the Googs App Engine and luckily for me, all my machines decided to puke except for my Windows 2000 Server. How ironic is that? In disbelief, I downloaded the Google App Engine SDK Windows installer and what do I get? I sense some pure, unadultered haterade. (j/k) Since Python is one of those insert_any_synonym_for_fun languages that just works, here’s how to get the Google App Engine SDK working in Win2K. Download the Linux/Other platform package and unzip to somewhere neat. Add a System Environment variable called ‘APP_ENGINE_HOME’ that points to your … -
DjangoSites Gets OpenID Support
OpenID is, in my opinion, critical in the success of an open web. It allows an individual to access websites without providing that website with a password, and it provides a single identity across non-homogeneous websites. Generally speaking, it also makes the signup process for a website much simpler. Rather than the traditional method of finding a username that isn't yet in use, entering a password, verifying your e-mail address, then selling your firstborn, with a system such as OpenID you simply enter your OpenID Identifier (typically, but not necessarily the web address of your weblog) and click 'Signup'. You then verify your username and password with your OpenID Provider (the only username & password you should have to remember) who returns you to the original website with a token saying "Yep, this really is the guy who says he's rossp.org." There are plenty of descriptions of OpenID works, so I won't harp on about it too long. Lets just say that I think it's an important development in todays web. Django got it's first dose of the OpenID 'syrup' from Simon Willison, who released his efforts as django_openidconsumer. This application lets you use OpenID on your website, however it … -
DjangoSites Gets OpenID Support
OpenID is, in my opinion, critical in the success of an open web. It allows an individual to access websites without providing that website with a password, and it provides a single identity across non-homogeneous websites. Generally speaking, it also makes the signup process for a website much simpler. Rather … -
Django geography hacks
If you need to handle some basic geography in your Django application, but can't or don't want to use GeoDjango, here are some quick hacks to accomplish simple geocoding and distance calculations. -
Localization options in Django
Was having trouble finding the language abbreviations everyone was using with localization. Apparently it’s a standard: ISO 639-1 Also when setting up localization you need to create a ‘locale’ folder. The location is your choice. Then add one by one the locales from the same level as where your locale folder is. So if ‘locale’ [...] -
History lesson
This has been going around -- give people a peek at what commands you run most often. I ran this on my server, where I spend most of my shell time: > history|awk '{a[$2]++} END{for(i in a){printf "%5d\t%s\n",a[i],i}}'|sort -rn|head 103 hg 81 cd 67 ll 29 ./manage.py 23 ab 21 re-ap 17 hgup 14 svn 13 cat 12 ls Notes: Mercurial has pushed my use of Subversion way down. I can't remember what I was benchmarking with ab, but I'm sure it's faster now! re-ap is my alias for restarting Apache (re-po restarts Postfix, re-my restarts MySQL, etc.). hgup is a simple shell script that updates the live instance of my site by fetching from the Mercurial repository in the staging instance. It would make a neat Django custom management command, but not one tied to a particular app. -
Function/Class '...' was not prepended with 'user_'
I'm currently configuring one of my extension for realurl within Typo3. My aim is to have the categories and subcategories of an article center within the url. But the functionality of lookUpTable does not suffice as I have to observe the nesting of the categories. So I choose userFunc and enter the values as given in the realurl documentation: 'fixedPostVars' => array( 'articlecenter' => array( 'userFunc' => 'EXT:extkey/class.tx_userxyz.php: &tx_realurl_userfunctest->main', ), ), then I clear the cache and it happens... nothing. Only a nice error message is presented: |Function/Class 'E' was not prepended with 'user_'| Seems that my configured values do not really reach the code they should. And of course that's the way it is. After some searching I detect that my configuration is wrong, because realurl is putting all configured values into a nested array wherein every key-value pair is put in as an array that has a numeric indice in the big array. (I hope you can follow my poor english). But my "userFunc" is not set up this way, its numeric indice is userFunc and the array with the key-value pairs is the string EXT:realurl/class.tx_realurl_userfunctest.php:&tx_realurl_userfunctest->main. As realurl runs through this array using foreach it has only "E" … -
Function/Class '...' was not prepended with 'user_'
I'm currently configuring one of my extension for realurl within Typo3. My aim is to have the categories and subcategories of an article center within the url. But the functionality of lookUpTable does not suffice as I have to observe the nesting of the categories. So I choose userFunc and enter the values as given in the realurl documentation: 'fixedPostVars' => array( 'articlecenter' => array( 'userFunc' => 'EXT:extkey/class.tx_userxyz.php: &tx_realurl_userfunctest->main', ), ), then I clear the cache and it happens... nothing. Only a nice error message is presented: |Function/Class 'E' was not prepended with 'user_'| Seems that my configured values do not really reach the code they should. And of course that's the way it is. After some searching I detect that my configuration is wrong, because realurl is putting all configured values into a nested array wherein every key-value pair is put in as an array that has a numeric indice in the big array. (I hope you can follow my poor english). But my "userFunc" is not set up this way, its numeric indice is userFunc and the array with the key-value pairs is the string EXT:realurl/class.tx_realurl_userfunctest.php:&tx_realurl_userfunctest->main. As realurl runs through this array using foreach it has only "E" … -
Function/Class '...' was not prepended with 'user_'
I'm currently configuring one of my extension for realurl within Typo3. My aim is to have the categories and subcategories of an article center within the url. But the functionality of lookUpTable does not suffice as I have to observe the nesting of the categories. So I choose userFunc and enter the values as given in the realurl documentation: 'fixedPostVars' => array( 'articlecenter' => array( 'userFunc' => 'EXT:extkey/class.tx_userxyz.php: &tx_realurl_userfunctest->main', ), ), then I clear the cache and it happens... nothing. Only a nice error message is presented: |Function/Class 'E' was not prepended with 'user_'| Seems that my configured values do not really reach the code they should. And of course that's the way it is. After some searching I detect that my configuration is wrong, because realurl is putting all configured values into a nested array wherein every key-value pair is put in as an array that has a numeric indice in the big array. (I hope you can follow my poor english). But my "userFunc" is not set up this way, its numeric indice is userFunc and the array with the key-value pairs is the string EXT:realurl/class.tx_realurl_userfunctest.php:&tx_realurl_userfunctest->main. As realurl runs through this array using foreach it has only "E" …