Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
SliceHost Recommendations for Django
Today I received an email about my recommendations for hosting Django sites on SliceHost. Below is the letter, then my ... -
Django projects
I’ve always thought that the sign of a healthy Open Source project is a vibrant ecosystem around that project. That’s why I’ve been thrilled to see that there are a bunch of cool third-party Django add-ons popping up. I thought I’d take a few minutes and give a shout out to some of my favorites. django-openid OpenID evangelist and Alpha Geek Extraordinare Simon Willison wrote this set of tools which lets your Django application become an OpenID consumer. -
Django Quick Tips #1.5: Manager Methods
In Django Quick Tips #1 I briefly discussed how using custom managers helps reduce the amount of code you’ll write. ... -
Django Newforms
Eu estava escrevendo um post completo sobre o newforms do django, quando eu vejo que eles atualizaram a documentação no site oficial hoje. E vários assuntos que estava abordando e que não tinham na documentação agora estão lá. Por isso vou deixar este post engavetado quietinho, quem saiba ainda precise dele?Mas para quem quer aprender ou saber mais sobre newforms ai vai umas dicas:A documentação oficial pode ser acessada aqui -> http://www.djangoproject.com/documentation/newforms/Na documentação oficial, aborda os seguintes temas:arquitetura do newforms que é formada por fields, widgets e forms.criação, validação e exibição dos formulários em html. criação de formulários a partir de um existente usando herança.documentação sobre os fields (novo)geração de formulários através do model ou instância.Há coisas que ainda não tem documentação como personalização de formulários gerados através de um modelo ou uma demonstração de como um model por interferir num form gerado pelo newforms, mas isso eu posso mostrar em outros posts.Abaixo alguns links sobre newforms que valem a pena serem lidos.http://pythonidae.blogspot.com/2007/03/django-e-o-quebra-cabea-com-newforms_27.htmlhttp://weblog.bignerdranch.com/?p=31http://eggdrop.ch/blog/2007/02/15/django-dynamicforms/http://code.pui.ch/2007/01/07/using-djangos-newforms/http://www.zoia.org/blog/2007/04/23/using-dynamic-choices-with-django-newforms-and-custom-widgets/http://unpythonic.blogspot.com/2007/01/django-newforms-for-models.htmlhttp://www.pkshiu.com/loft/archive/2007/04/custom-validation-in-django-newforms-library -
I have a Slice and you don't
I have a Slice and you don’t (probably)! SliceHost has quickly outgrown themselves and have a wait list of up ... -
Going International, pt. 3: Implementation of multilingual content
Introduction As I wrote in the two previous posts, I wanted the URLs of this site to contain the language the content is in. To do this, I had to write some custom code, including models, managers, middleware and context processors. Models The first step on having multilingual content is to define a model that can support it. I thought long and hard and it boils down to these conclusions: The same content in different languages shares some data, like the slug, the tags and the publication date The different data are the title, the summary and the body. Therefore, I have to find a way to "inherit" the shared data to the actual entries, while keeping the different data apart. Model inheritance in Django is somewhat rough, and so I went with KISS: Keep it simple, stupid, and went with the simplest thing that might just work: First, define a master entry: class MasterEntry(models.Model): slug = models.SlugField( unique_for_date='pub_date', prepopulate_from=('title',), help_text='Do not add language info here.' ) pub_date = models.DateTimeField() tags = TagField() enable_comments = models.BooleanField(default=True) class Meta: ordering = ('-pub_date',) get_latest_by = 'pub_date' class Admin: list_display = ('pub_date', 'slug') list_filter = ('enable_comments', 'pub_date') search_fields = ['slug','tags'] date_hierarchy = 'pub_date' … -
Going international, pt. 2: URL design
To help myself developing the international part of this blog, I've made some usage scenarios, which I write down here, partly to not forget them but mostly to help find any mistakes and omissions. So here they are: The users: Giannis (Greek, computer savvy user, has his browser correctly set) Takis (Greek, lives abroad, doesn't have access to the language settings) I could also define two English users in similar situations, but there's no point as it turns out that they just mirror each other. I have to point out a seemingly little-used preference of web browsers, the language selection preference. This sets the HTTP header 'Accept-Language' so that a server can know, erm, the language preference. This is basic stuff but not many users bother to change from the default setting. URLs and design The pages: /el/1/ Direct link to a greek page, content isn't available in english. /en/2/ Direct link to an english page, content isn't available in greek. /el/3/ Direct link to a greek page, content is available in english. /en/3/ Direct link to an english page, content is available in greek. Also, there are two little flags on the top right of the site that allow … -
djanger = Django developer
Durante uma conversa com o Marinho, onde estávamos falando sobre a falta de sistemas em django, como cms, blogs, wikis e acabou saindo uma nova expressão: djanger, onde djanger é a pessoa que utiliza o django.Sent at 12:22 PM on SaturdayAndrews Medina: heheh verdade :pMarinho Brandão: … e ir oferencendo o serviço a djangers (essa expressão eu acabei de inventar… ehhe ) e ganhar dinheiro com AdSenseNessa conversa tambem nasceu um novo projeto o 'bingo!'. Ainda não sei se será esse nome mesmo, mas em breve terão notícias sobre ele. -
Captcha no django
Você quer evitar spams em seus sistemas feitos em django?Seus problemas acabaram! Existe um projeto opensource da verificação capctha para django. Este projeto utiliza os newforms o que é algo muito bom, já que a maneira antiga de tratar formulários no django tende a ser extinta.Para saber mais sobre o projeto acesse: http://www.lostlogicx.com/captchasblow/ -
Enfim o django 0.96
Dia 23 de março foi anunciado no blog oficial do django o lançamento da versão 0.96 do django.O objetivo principal dessa versão é deixar estável, algumas coisas que foram iniciadas na versão 0.95 e nisso haverá incompatibilidades na mudança de versão.A principal incompatibilidade está relacionada ao driver para MySQL, o MySQLdb. Se a versão que você utiliza for anterior a 1.2.1p2, você terá que colocar no settings 'mysql_old' em vez de 'mysql', se a versão do driver for a 1.2.1p2 ou mais recente continua a mesma coisa.Como muitos ja esperavam, o newsforms que é a nova biblioteca para geração e manipulação de formulários é a padrão. Se você quiser continuar usando os oldforms é só importar os oldforms como forms da seguinte maneira:from django import oldforms as formsEntre as outras novidades está:Uuma ferramenta para testes.Melhoria na parte de serialização, com novos formatos, suportando JSON, XML e Python ( gerando listas, dicionários, strings )Melhorias também na configuraçã ode URLs, antes só era permitido strings com o caimnho inteiro indicando uma função duma view, agora é possível importar essa função com o import do Python e apenas chamá-la. Ex:from django.conf.urls.defaults import *from mysite.myapp.views import myviewurlpatterns = patterns('', ('^myview/$', myview))E para finalizar foram … -
Mais um site feito em django com o fonte liberado!!!
Tá virando mania mesmo!Tudo começou quando o JeffCroft resolveu liberar o código fonte de uma projeto que ele tinha feito em django o LOST-theories.com. Esse foi seu primeiro projeto em django. Mesmo com o grande crescimento da comunidade OpenSource e com a idéia de que algo assim poderá ajudar muitos a aprenderem a fazer o que você sabe, podendo ajudar a comunidade estarem bem difundidos, ainda é raro vermos algo assim.Lógico que tem projetos opensource em várias linguagens são faceis de achar, como o Drupal por exemplo. Mas liberar o código fonte de um site comercial, só para mostrar como foi feito é algo que não se vê todo dia.Muita gente viu e curtiu! E o resultado disso foi mais dois sites repetirem o ato: o CheeseRater e o DjangoSnnipets.org.Vendo a ação feita pelo pessoal do DjangoSnnipets, o Chris McAvoy liberou através do google code, um projeto para podcasts em django.Nisso já são 4 projetos, um vendo o outro e seguindo o exemplo. Isso me faz lembrar do filme: 'A corrente do bem'.Agora falta só você também fazer parte dela ( e eu também né ).A comunidade django agradece!Ai estão o link para os fontes dos projetos:http://code.google.com/p/tastebud/http://code.google.com/p/cab/ http://code.google.com/p/django-registration/http://www.cheeserater.com/ ( o … -
Django + Apache no Windows
Com a crescente divulgação do django aqui no Brasil, muitos estão começando a testar e usar esse WebFramework.A maioria dos desenvolvedores usam o 'manager.py runserver' para fazerem seus testes com django no windows, ou por falta de necessidade de usaru m servidor para testes ou por não conseguir configurar um.No post de hoje vou mostrar a instalação e configuração do Django em ambiente Windows utilizando apache + modpython.Os programas utilizados são:Python 2.4.4Apache 2ModPython 3.2.8Django 0.95.11 - Instalando o PythonPara instalar o Python no Windows é só dar duplo clique no arquivo .msi e seguir o guia de instalação2 - Instalando o ApachePara instalar oapache no windows é só dar um cuplo clique no executável e seguir o guia de instalação.Para testar o apache é só acessar http://localhost3 - Instalando o modpythonPara instalar o modpython é só dar um cuplo clique no executável e seguir o guia de instalação. No final da instalação é só informar a pasta em que o apache foi instalada.Depois abra o arquivo 'http.conf' que fica dentro da pasta 'conf' do apache e adicione esta linha:LoadModule python_module modules/mod_python.so4 - Instalando o djangoDescompacte o arquivo .tar.gz baixado no site do django.Abra o prompt de comando, geralmente encontrado em … -
Lançado o Bingo!
Depois do anúncio aqui está o lançamento. Este ainda não é o lançamento oficial, mas já está disponível no google code o código fonte do bingo. Para quem não sabe o bingo é um CMS desenvolvido em django. O blog, wiki, feeds RSS e atom já estão em funcionamento, mas há várias coisas a serem resolvidas, como os comentários e cadastro de usuários. Para as tags usamos o django-tagging. O marinho, meu parceiro no desenvolvimento do bingo colocou uma versão do bingo no ar para ver acesse http://marinho.webdoisonline.com/blog/. Também foi criado um grupo de discussão para o grupo de desenvolvimento do bingo. Se quiser participar é só se inscrever. O e-mail do grupo é bingo-developers@googlegroups.comSó lembrando que ainda não foram lançadas nenhuma versão release, mas em breve lançaremos o 0.1.Para acessar o código fonte do bingo via svn use:svn checkout http://bingo.googlecode.com/svn/trunk/ bingo -
CMS em Django? bingo!
Depois de um tempo de pesquisa concluí:Ao contrário das outras tecnologias, não há nenhum CMS, Wiki ou algum sistema do tipo feito em django.Se pensarmos em zope, pensamos em plone. Se pensarmos em php logo vem wordpress, phpnuke, phpbb. Se pensamos em java temos o JavaBB, JavaFreeCms entre outros.Mas porque não há nada parecido em django?Uma das razões é porque é tão facil criar um wiki no django que ninguem vai querer um pronto.Foi ai que decidi: vou criar um CMS feito em django e seu nome será bingo.O bingo integrará Wiki, Blog, Galeria de fotos, feeds entre outras coisas.O grande barato do bingo é que o foco dele não serão somente os djangers, e sim pessoas comuns que querem ter seu wiki ou seu blog ou páginapessoal, sem precisar mexer nos códigos.Mas, quando anuncei o bingo! na lista de e-mails do django-brasil, muitos djangers se interessaram, e ainda mais, se alistaram para ajudar o projeto. E ainda mais o site da comunidade django-brasil usará o bingo!.O bingo! ainda é um projeto em nascimento, mas já nasceu com o pé direito.Está querendo ajudar? Está ancioso para utilizar?Aguarde..... -
How to add a preview page
When using the django web administration page to add blog posts, it's nice to be able to preview the post to catch layout glitches, typos and markup issues. The best way to do this is to have a preview page. To add a preview page, the model should have: a boolean field that determines whether the post is public or not a smart get_absolute_url function. Separate your posts The first is easy: is_public = models.BooleanField(default=False) Make your URLs smart The second: def get_absolute_url(self): if self.is_public: return "/%s/blog/%s/%s/" % (self.language, self.pub_date.strftime("%Y/%m/%d").lower(), self.slug) else: return "/%s/blog/preview/%d" %(self.language,self.id) The django admin uses the get_absolute_url function to put a "Display on site" button on an object's page. So when you have public entries, you get to see what all the world sees, but when an entry is not public, the get_absolute_url function returns a special url. Add a pre-view The final piece to the puzzle is to have a view that is protected: @login_required @user_passes_test(lambda u: u.is_staff) def entry_preview(request, entry_id): entry = get_object_or_404(Entry, pk=entry_id) return render_to_response('entry_detail.html', {'entry':entry}, context_instance=RequestContext(request)) I use the is_staff property, but this can easily be changed to something else. Don't forget to add the relevant url to your urls.py : (r'^preview/(?P<entry_id>\d+)/$', … -
Going international, pt. 1
Introduction From the start, I was interested in making the content posted here available in two languages: Greek and English. This is no small feat, and I thought long and hard on how to make it possible and get it working just the way I like it. So here is a rundown of how internationalization works here: The prerequisites are not many: Make the content available in both languages. Make the interface available in both languages. I have slacked and made the tags English-only. Maybe I'll fix that later on, but it'll do for now. Approaches Now, you have two choices about making a site handle international visitors. You either: let them decide what language they prefer, by providing the choices somewhere in your interface or, try to use their request data (like the IP address, or the language preference sent by their browser) to decide their preferred language. The first approach is the most foolproof, as a user explicitly chooses his language. He can't be wrong, can he? But, there is a snag: what is the first page he sees? If it is in his own language, there's no problem. But if it is in another language, he'll get … -
Django Quick Tips #2: Image Thumbnails
One of the most common tasks in web development is resizing uploaded images into thumbnails of the original. Today I’ll ... -
Building My Django Weblog: Part 6
Very early on, when I was still playing with the look and layout of the website, I asked my friend Lisa. At the time, I was still just running the django development server. Anyway, Lisa has a great mind for web standards and the evolution of web markup. So she immediately picked up on the fact that my pages had a doctype of Transitional HTML 4.01 and gave me quite a bit of a lecture on things I should do instead. She recommended going with at least strict HTML 4.01, but preferably with XHTML. At the time, I wasn't sure what any of that meant (and I'm even still learning my way through it). So, anyway, I launched the website a few weeks later, with a few things not quite working the way they should have been. Content types were one of those things. One of the first bugs that got reported was by James Rowe: he saw, in my atom feed, that lists and block quotes and other things had embedded paragraph tags (<p>...</p>). And so in some cases, I had nested paragraph tags. Here's what happened. In Django's admin, when you have a text field, you just type … -
Django Internships at the Journal-World
I’m extremely excited to announce our new internship program here in Lawrence. Starting this summer we’re going to be hiring interns to join our kick-ass team and learn the ropes. If you’re a student, or if you’re trying to break into the world of next-generation web development, I can’t think of a better place to get started. You’ll get to spend up to six months developing cool toys (in Django, of course), live in one of the coolest towns in the country, and learn web development from the best. -
Upgrading Ubuntu for Django Users
I just updated my Slice from Ubuntu Dapper (6.06.1), the currently available version from Slicehost, to Ubuntu Feisty (7.04). I ... -
Amazon S3 Updates Pricing
Amazon just sent out an email to AWS developers. S3 has a new pricing model, which actually reduces cost: Current ... -
Another django-restful-model-views Update
As I mentioned a few weeks ago, Andreas Stuhlmueller has proposed a general REST API for Django, and as his ideas and mine seemed very compatible, we began talking about collaborating on a joint solution. -
[EN] Django model managers, Do Not Repeat Yourself !
I've recently come up with a great django feature "model Managers".Each django model has it's own manager class, which can be overriden by your custom class.Let's say there's a model containing fields:class Person(models.Model): name = models.CharField(maxlength="100", blank=False, verbose_name="Your name") age = models.IntegerField(verbose_name="Your age") def __str__(self): -
[EN] Django extending User, custom User methods
Django doesn't allow to subclass the User model yet.Each Django model lets you easily create model methods.Behind the scene, each django model has its own methods, f.e. save()which saves the model data into the database.Django provides the lightweight User framework in "django/contrib/auth/",where "User" model is defined with fields:username, password, is_staff, first_name, last_name, email, -
URL Pet Peeves
One of the best features of Django is the clean URL structure. The following is an example of what could ...