Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
django CMS 2.2 release candidate 2 available
django CMS 2.2 release candidate 2 available -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por hi
There are thousands of blogs that requires comments on them. What is the intention of blog comments? -
Quick, simple and arguably proper Ajax (without touching server-side)
I don't always ajaxify things, but when I do, I first try to do it as simply as possible. I have some biases about ajax (for example, it should be supplementary to the normal form behaviour), and they suggest a very simple and quick solution for ajax. -
Django'da Aggregate ve Annotate
Django veritabanı yönetiminde annotate() ve aggregate() kullanarak,satırların toplamı, ortalaması gibi, veritabanında birden çok satırdan veya ilgili diğer tablolardan bilgi toplayarak bulunması gereken değerleri bulabilirsiniz. annotate() ve aggregate() metodlarının farkı, aggregate'in tüm tablo için tek bir sonuç döndürmesi, annotate'in ise veritabanındaki tüm satırlar için ayrı birer değer oluşturmasıdır. Bu yazıda kısaca Django'da annotate ve aggreate kullanımı ile ilgili örnekler göstereceğim.Burada anlatılanlar kısaca django'da annotate ve aggregate nasıl kullanılır konusuna giriş yapmak içindir, daha fazlasını django belgelerinde aggregate ile ilgili bölümden bulabilirsiniz. Tablo alanlarının ortalaması ### # models.py ### from django.db import models class Urun(models.Model): fiyat = models.PositiveIntegerField() ### # Tüm ürünlere ait ortalama fiyatları almak istediğinizde ### from uygulama_adi.models import Urun from django.db import Avg a = Urun.objects.aggregate(Avg('fiyat')) # a = {"fiyat__avg": 23.56} -> bir dict objesi döndürür. # Dönen sözlükteki anahtar adını da ayarlayabilirsiniz. a = Urun.objects.aggregate(ortalama_fiyat=Avg('fiyat')) # a = {"ortalama_fiyat": 23.56} ## # Birden fazla değer hesaplamak ## from django.db.models import Max, Min a = Urun.objects.aggregate(Ortfiyat=Avg('fiyat'),Minfiyat=Min('fiyat'),maksfiyat=Max('fiyat')) # a = {"Ortfiyat" : 15.23, "Minfiyat": 3, "Maxfiyat" : 28} Django'da annotate kullanımı Bir istem kümesindeki (QuerySet) tüm değerler için aggregate almak için annotate kullanılır. Çoğu zaman annotate m2m (çokdan çoğa) ilişkilerde kullanılır. ### # models.py ### from django.db import models class … -
Django'da Aggregate ve Annotate
Django veritabanı yönetiminde annotate() ve aggregate() kullanarak,satırların toplamı, ortalaması gibi, veritabanında birden çok satırdan veya ilgili diğer tablolardan bilgi toplayarak bulunması gereken değerleri bulabilirsiniz. annotate() ve aggregate() metodlarının farkı, aggregate'in tüm tablo için tek bir sonuç döndürmesi, annotate'in ise veritabanındaki tüm satırlar için ayrı birer değer oluşturmasıdır. Bu yazıda kısaca Django'da annotate ve aggreate kullanımı ile ilgili örnekler göstereceğim.Burada anlatılanlar kısaca django'da annotate ve aggregate nasıl kullanılır konusuna giriş yapmak içindir, daha fazlasını django belgelerinde aggregate ile ilgili bölümden bulabilirsiniz. Tablo alanlarının ortalaması ### # models.py ### from django.db import models class Urun(models.Model): fiyat = models.PositiveIntegerField() ### # Tüm ürünlere ait ortalama fiyatları almak istediğinizde ### from uygulama_adi.models import Urun from django.db import Avg a = Urun.objects.aggregate(Avg('fiyat')) # a = {"fiyat__avg": 23.56} -> bir dict objesi döndürür. # Dönen sözlükteki anahtar adını da ayarlayabilirsiniz. a = Urun.objects.aggregate(ortalama_fiyat=Avg('fiyat')) # a = {"ortalama_fiyat": 23.56} ## # Birden fazla değer hesaplamak ## from django.db.models import Max, Min a = Urun.objects.aggregate(Ortfiyat=Avg('fiyat'),Minfiyat=Min('fiyat'),maksfiyat=Max('fiyat')) # a = {"Ortfiyat" : 15.23, "Minfiyat": 3, "Maxfiyat" : 28} Django'da annotate kullanımı Bir istem kümesindeki (QuerySet) tüm değerler için aggregate almak için annotate kullanılır. Çoğu zaman annotate m2m (çokdan çoğa) ilişkilerde kullanılır. ### # models.py ### from django.db import models class … -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por 4986243
4986243 beers on the wall. -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por coed summer camp
Thank you for this excellent article. I especially enjoyed reviewing it and ought to talk to everyone. -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por Valder
Sorry, i don't wanna make malling. You can user rss feed, twitter or facebook for this :D -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por Valder
Try this tutorial: http://www.quickonlinetips.com/archives/2006/03/import-blogger-posts-comments-to-wordpress/ -
3rd Year Project: Back to Backtrac
After contacting the university regarding my 3rd year project/dissertation, my ideal choice has been confirmed. I'll be making a distributed backup system, based around a Django web interface and AMQP. Backtrac is a pretty old project, and one whose name I am likely to change once I'm working on it. It was started in my first semester of university last year, when I didn't have enough work to keep me busy. I didn't know enough about Django back then, though, so it was left unfinished and only half-working. Now I think I know enough to pull this off, and it's a chance to do something I really enjoy - while getting marks for it in the process! If everything goes to plan I'll be supervised by Dr. Julie Greensmith, which I'm really looking forward to. I'll be using an app called Celery to handle the background tasks, which will be simple "pings" to the client machines, telling them to start a backup. Celery uses AMQP, provided by a broker such as RabbitMQ (which is written in Erlang). It's usually used for processing intensive computational tasks, but can also be put to use for jobs that need executing on a periodic … -
Using Django Authentication with Twisted Perspective Broker
For my third year project, I have hooked Twisted's Perspective Broker authentication into Django, so that a networked application can authenticate itself against Django's central user database (django.contrib.auth). The process is pretty quick and easy, thanks to Twisted's pluggable nature, and Django's pure simplicity. The Checker Firstly, we create a class which will actually do the "checking", to allow access (or not) given a username/password combination. That looks something like this: auth.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 from zope.interface import implements from twisted.python import failure, log from twisted.cred import portal, checkers, error, credentials from twisted.internet import defer from django.contrib.auth.models import User, check_password class DjangoAuthChecker: implements(checkers.ICredentialsChecker) credentialInterfaces = (credentials.IUsernamePassword, credentials.IUsernameHashedPassword) def _passwordMatch(self, matched, user): if matched: return user else: return failure.Failure(error.UnauthorizedLogin()) def requestAvatarId(self, credentials): try: user = User.objects.get(username=credentials.username) return defer.maybeDeferred( check_password, credentials.password, user.password).addCallback(self._passwordMatch, user) except User.DoesNotExist: return defer.fail(error.UnauthorizedLogin()) This code is relatively self-explanatory, once you understand Twisted's way of doing things. An authenticated "user" in Twisted (though this might not actually be a person) is called an Avatar. The requestAvatarId method therefore takes a set of credentials, and returns … -
The End of an Era
Well, here we are. Three years at The University of Nottingham, and what do I have to show for it? Well, this is what: That's right! I have a recommendation for a first in Computer Science. It turns out both my supervisor and second marker were fond of my dissertation - Backtrac Backup System - and would like to see it used in a commercial setting. I also had my work sponsored by Servat Ltd., which went down very well with the powers that be. I've enjoyed my time at university, but I'm ready to move on now. Or at least, I'd better be, after turning down a couple of very good offers for PhD studentships. So what's next? Why, I'm glad you asked! I'm currently working on a (secret) project with Marcus Whybrow, which will hopefully shape up to be something quite special. It is, of course, a Django project, and it's teaching us both about the finer details of developing and deploying a production system. There's a few posts in the pipeline about the things we've discovered this far, and we've hardly got going yet! This time around, we've decided to go with a brand new web server … -
MyUni and Django 1.2
MyUni is hailed as my "latest venture" on the front page of my website. In fact, it was conceived early last year, when I was in my first year at Nottingham University, by Rob Miles and Ben Jenkinson. We were only just starting to get to grips with this new fad, called Django. The project has gone through several iterations since then, never really reaching any form of completeness. This time round, we are using proper version control (thanks to Mercurial and BitBucket), and trying to adhere to Django best practices as much as possible. Straight from the repository website: MyUni is a portal-style web application for Universities, offering studentsa central location to access all the relevant information about their course,modules, assignments, and staff members. The project came about because of a passionate hatred for the WebCT system that our university is using, and a general feeling that things could be (and should be) better. Django 1.2 will bring some really exciting new features, which I am sure would make developing and using MyUni a better experience. One of the things I'm most looking forward to using is the messages framework. I plan to use it for a bunch of … -
Extending Settings Variables with local_settings.py in Django
I discovered this hacky way to use the local_settings trick to extend and/or override values in the main Django settings file today. Some projects use a "reverse" version of the local settings trick (which is explained below), whereby the main settings file becomes settings_local.py or something similar, which first imports settings.py, and then extends or overrides the values as required. I didn't want to change the name of the project settings file to settings_local.py, however, as it would mean changing the WSGI file on every server that the project runs on. The Local Settings Trick It's a well-known trick to use a file called local_settings.py or something similar, with a piece of code at the bottom of the main settings file: settings.py 1 2 3 4 try: from local_settings import * except: pass This allows you to override the value of settings variables. It won't work, however, if you wish to extend a settings variable (for example, adding an app to INSTALLED_APPS). For this, I have found that the following ugly hack seems to do the job. The Ugly Hack For this hack, replace the snippet at the bottom of the main settings file with the following code: settings.py 1 … -
The Trials and Tribulations of Django + Git
I just finished my last exam today - Web Programming and Scripting - which explains the distinct lack of activity around here in recent times. Thankfully I could end my exam season on a high, as web programming is, well, what I do - so it wasn't too much of a challenge! Something strange happens to me every time exams come around. I seem to pick up new projects, and just run with them. This time, I've become involved with a small group of people at university, writing a portal-style information system for universities. I suppose most people call this behavior procrastination, but I'm quite deeply in denial about that. Ever since my post about the Backtrac Backup System, I've been really enjoying using Django. Something about it just makes developing for the web, well, exciting. That can only be good, right? I am the designated server administrator for this latest project, mostly due to the fact that I am the only one with a server to administer, and some of the things I've learned so far seem worthy of a mention here. Firstly, we as developers were - how can I put it - stepping on each other toes … -
It Begins...
The country has just undergone a mass-exodus of university students from their parents' houses back into halls. I played by own small part in blocking up the roads moving back into university accommodation this weekend, and it's all gearing up for the new school year. I've been working with Django more and more lately, and I've written my first "commercial" application using my new favourite framework - a booking system for taught causes at the City Council. I'm really enjoying writing web applications with Django, and I'm sure this blog will start to resemble a web-developer's in the near future. Also, I'm really looking forward to this year at university. As I understand it, there's a lot more work to be done, but the software engineering group project should be fun - as long as my "randomly chosen" team are happy with us using Python! -
Backtrac Implementation - The Major Decisions
Thinking a lot about my 3rd year project, I've been considering how to implement a backup system based around a Django server. So far, I have reached the conclusion that the system will consist of three main parts: The Django server (yet to be named) The client daemon (backtracd) The backup library itself (backuplib) As I mentioned in the previous post, the Django server will be based around Celery. This will offer me the ability to schedule a task for a certain date and time in the future, which is a huge part of the implementation taken care of. One thing I am yet to figure out, however, is how the server will communicate with the client daemons. At the moment I'm thinking XML-RPC, but it seems to me that it will end up a sort of mish-mash of different technologies - as the Django server will be exposing a JSON API (probably via Piston). I have also considered running Django on the clients too, so everything can use JSON/Piston, but this seems at the moment like an unnecessary burden. Another thing to consider is the data that is to be transmitted between the nodes. Should I use a bunch … -
Django on twistd.web.wsgi - Issue Workaround
My last few posts have generally been about my final year project - Backtrac Backup System. One of the recent challenges I faced was getting the Django-based web interface to run under the Twisted WSGI server. In this post, I'll describe a major issue with this process, and how I worked around it. TAC or TAP? When Twisted is installed, it places an executable program called twistd on your path. The purpose of this program is to run a twisted application as a daemon, and manage all of the tricky daemonization code for you. This includes things like forking, PID files, and logging. There are two ways to describe your application two the Twisted daemon: TAC files and TAP files. I'm pretty sure that TAC stands for Twisted Application Configuration, whereas TAP stands for Twisted Application Plugin. The difference between the two, it seems, is that TAC files pass an Application object to twistd, while TAP files pass a ServiceMaker object (whose purpose is to return a Service object, when makeService is called). Also, given that TAP files define aServiceMaker object which Twisted will call a method on, we can accept a parameter called options, which contains the parsed command-line … -
Django Staging Server: Apache Configuration
In this post, I'd like to talk a little about how my staging server (called Kaylee, after the character from Firefly), is configured to run the multiple Django projects that I have on the go. A lot of the other articles I have read on this subject use mod_python but my server is configured to use WSGI, so that's what I will be going over in this post. Beginnings Firstly, I use virtualenv to keep the Python environments for the different projects separate, but that's a topic in itself. This isn't a requirement, but it helps if you have dependencies that you don't want installed system-wide, or projects that use different versions of a particular package. You can read more about virtualenv and Django here. The directory structure for my /opt/webapps/ directory looks something like this: webapps/ |-- apache | |-- coral.conf | |-- coral.wsgi | |-- myuni.conf | `-- myuni.wsgi |-- coral | |-- env | `-- repository |-- myuni | |-- env | `-- repository The two projects shown here are Coral Issue Tracker and MyUni. The directory for each project contains the virtual env for that project, and the repository. Alongside the project folders is a directory … -
Django Model Templates (sans-Denormalisation)
I came across an interesting problem recently, while trying to model the structure of a university course in Django. The model needed to represent the notion of a university module, which can be taught over a number of semesters and/or years, by different people, and with different students each time round. Some information remained common to each of these modules however, such as the code, name, and type of the module (single semester or full-year). One solution that crossed my mind was to use a sort of template, and copy the common information over each time the module was taught. This would mean duplicating the common fields over a template model and the module's model, and copying the data every time a new "Module" object gets created. This just didn't sit well with me though, as I really don't like denomalising data when it's not absolutely necessary. The solution I have settled on (for now, anyway) works something like this: I use the model template idea, but with a foreign key from the Module to it's template. Then, to access the fields on the template directly from the Module model, I use a combination of the Python property and a … -
My Latest Project: BackTrac Backup System
My life has been pretty busy as of late, mostly with a new project I am working on called Backtrac. I am developing a network backup solution, written entirely in Python - using the Django framework as a front-end web interface. This came at quite a good time, as I've been asked to give a presentation on any highly technical topic, on which I know my stuff. The plan is to use Backtrac as a base, and to explain the technical concepts behind the system that make it work. The things I am going on concentrate on are: Pyhon in general XML-RPC Filesystem hardlinks The MVC concept, and Django This should be enough content to fill a 15-minute slot, I hope. Now I'll explain a little bit about how Backtrac works, for the benefit of those not coming to the presentation. What I wanted to achieve with Backtrac was a smart backup system, that doesn't necessarily have to be the fastest. I wanted a very detailed web interface, with scheduling capabilities and log view. I decided on Django for this, seeing as I had already decided on Python for the system itself. The nodes in the system use XML-RPC to … -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por Katharine Vaquez
Thanks - Enjoyed this article, can you make it so I get an alert email when you make a fresh post? -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por Valder
Yes, I had thought to remove these two columns, but I never have time to improve it ... -
Comentário sobre Configurando um projeto Django no UOL Host – segunda parte por Oak Furniture
I ran into this page accidentally, surprisingly, this is a amazing website. The site owner has carried out a superb job of putting it together, the info here is really insightful. You just secured yourself a guarenteed reader. -
Quản lý subsite với django
Khi phát triển một website cho các hệ thống quản lý và thương mại, chắc hẳn mọi người sẽ gặp một bài toán như sau: "Ví dụ bạn xây dựng một website abc.com và muốn khi người dùng đăng ký với tên là xyz thì sẽ tự động tạo ra một site cho người dùng dưới dạng http://abc.com/xyz hoặc tên miền mà người dùng lựa chọn". Với bài toán như vậy chúng ta sẽ xây dựng website ra sao để có thể quản lý được các site con như vậy?Đây là một bài toán mà nhiều người đã và đang giải quyết. Nếu sử dụng các hệ thống có sẵn như Joomla, Drupal, Wordpress hay Plone thì đã được hỗ trợ phần nào. Với Django thì bạn thực hiện bài toán đó như thế nào? Được truyền cảm hứng từ bài viết của pduyha (Cấu hình Apache với nhiều Django site), với cách làm trên thì mỗi lần tạo một site mới chúng ta phải restart lại Apache (hoặc có cách reload). Nhưng khi số lượng site lớn dần thì công đoạn đó sẽ mất thời gian đáng kể. Bên cạnh đó sẽ có sự lãng phí tài nguyên và …