close forgot it?
close
Login with password or OpenID

Archive for September, 2008

Customizing the Admin Forms

There is a lot written on how to customize the design and general data on the admin interface. In this post I will ask a little bit separate question: How can you customize only a small portion of the form generated by the admin app?

The solution is kind of easy. As an example I will take a code snippet from the byteflow blogging engine. Our problem was that the blog engine automatically registers everyone who comments on your blog. As a result, after a couple of comments it is rather difficult to find yourself in the list of authors when you would like to write a new post.

The model-based solution

Our Post model defined the author field as

author = models.ForeignKey(User, related_name='posts')

We can achieve a restricted selection by simply adding a limit_to parameter to ForeignKey. So we would get

author = models.ForeignKey(User, related_name='posts', limit_choices_to={'is_staff: True'})

But then we get the idea of having the actual user preselected! This is a simple feature, but still saves you some seconds on really boring administrative tasks.

The admin inheritance solution

If you have a look at an admin interface definition it is obvious that you could use inheritance, and simply overwrite only one method. The one that generates the form!

class PostAdmin(admin.ModelAdmin):

By checking the original ModelAdmin class it was easy to find out that the form is actually created by its get_form method. So you just have to define this same method in your PostAdmin class, and customize the form as you like!

def get_form(self, request, obj=None, **kwargs):
    form = super(PostAdmin, self).get_form(request, obj, **kwargs)
    form.base_fields['author'] = forms.ModelChoiceField(label=_('Author'), queryset=User.objects.filter(is_staff=True), initial=request.user.pk)
    return form

As you can see, the first line just calls real get_form method. While the modifies it according to our needs. Here we actually recreate the author field, but probably (someone more literate in the newforms library) could simply set the initial value as well.

How to Play the Piano Online

After almost 20 years I restarted my piano studies.

First I thought to find a piano teacher, but it turned out not to be feasible, moreover as I have some basics, it seemed to be a good idea to start it on my own, and look for a teacher later only. So, I Googled for “online piano lessons” and similar items.

Now, that I am already able to play simple things, I would like to collect you the links I used, in the order I would recommend them to be used.

  1. Get a piano. In my case this is the only reason why I am sharing a flat with a crazy german. :)

  2. You should definitely start with Learn Piano Online. Actually, this link is already for registered users, but never mind. :) This website is simply amazing in letting you play your first tunes! Lisa (the teacher) is really nice, and you might prefer to sign up. They have a newsletter, a facebook account and a blog as well.

  3. Once you are over the lessons, go and practice a bit in the “Instant Play” section. Actually, the majority of the sheets here are useless, but you will at least be able to play the “You are my sinshine”

  4. Head over to G MAJOR MUSIC THEORY for more sheets and their amazing music theory worksheets. Right now I am already able to play the Primer Level at first, and I am struggling with Level 1 sheets.

  5. Hmm, this is a good question. If you have any ideas, please share it with me!

    I’ve found Hear and Play who claim to teach you to play after hearing. This would be really nice, but I am a bit suspicious, as they always try to sell me all kind of (piano related) things, and would teach me to play after hearing without ever touching a piano first. This is a bit strange. Anyway, it might be a good source later.

Internationalization Aware Development

I am sure that every serious programmer knows that the code he writes should provide at least basic i18n (and possibly l10n) features, but given lack of language knowledge, I have the feeling that it is harder than one might think.

So let me give you my golden rule, and some examples. Please, give yours in the comnents!

Always translate a whole sentence, not just parts of it.

What do I mean by this? The byteflow code for example contains {% trans ‘Archives for ‘ %} {{year}} of yourse this makes sense in English and probably many latin, german or even indo-european languages, but it Hungarian translation is for example a big mess as it reads “for September 2008 archives” (originally 2008 szeptemberi archívum).

The previous expression should be coded with blocktrans as {% blocktrans %}Archives for {{ year }}{% endblocktrans %}

Disclaimer: I am not an internationalization expert, but as I speak around 6 different languages (not including the programming languages) I appreciate the great diversity and beauty of the hundreds of cultures around us, and I think all of them are worth our support.

Google telefon Európában?

Most hogy közeledik a Google telefon megjelenése felettébb izgalmas hírek keringenek a médiában. Engem leginkább az érdekel, hogy mikorra érkezik majd meg a Google phone Magyarországra vagy Franciaországba (a francia részről lejjebb).

A ReadWriteWeb fent linkelt cikke szerint 2009 első negyedévére tervezi az európai bevezetést. Természetesen, a T-Mobillal. Miért is érdekes ez az állítás? Azért, mert Európa jelentős részében a T-mobil nemrég vezette be a Google phone legnagyobb vetélytársát, az iPhone-t.

Ezek után érdemes elgondolkozni azon, hogy vajon megéri-e neki most egy másik hasonló terméket bevezetnie, és ezzel a saját piacát rombolni. Lássuk, (kit helyzetkép után) mit is mond erről a közgazdasági elmélet!

 continue reading

James és a Linux

Az alábbi egy rövid esettanulmány, hogy alapvetően Linux-ellenes lakótársam, hogyan cserélte le a (legális!) Windowsát Ubuntura.

James mindig is kicsit viccesen nézte, hogy én Linuxot használok. Miután nem nagyon szereti a számítógépeket, ezért mindig is félt tőle, hogy ez biztos valami programozóknak való hecc. Így teljesen váratlanul ért, amikor idén augusztusban megkért, hogy adjak már neki egy telepítő CD-t, mert vírusos a gépe.

De lássuk, így két hónap távlatából hogyan értékeli az átállást?

 continue reading

Presenting Postimage for Django

When I wrote the first posts to the blog I realized that it would be extremely handy to be able to upload and include files into a post that I am just writing. So, I went on and wrote Postimage, a Django application that does just this!

After I quickly integrated it with byteflow, and now it is included in it by default.

 continue reading

My favourite Firefox extensions

As I have many friends who are amazed by the speed I use my browser, I decided to give a quick overview of what I use. The first part is easy to copy, you will simply need to install some extensions. This is presented in this article. The second part (another article) might be harder as that will be about the keyboard shortcuts that I like, but many don’t know about. So you will have to learn them first.

 continue reading

Korai és késői szabványosítás

A népszerűséghajhász Szabványok és Háborúk cikk után következzen egy másik kedvencem, Choi: Standardization and Experimentation.

Miért szeretem ezt a nagyon egyszerű cikket? Két okból, egyrészről mert egyszerű. Másrészről pedig mert eloszlatta egy tévhitemet.

 continue reading

Code Review Culture

I’ve found this post interesting enough for a repost. LP stands for Launchpad.

It’s about the inherent problems of code review and a proposed redesign of the process.

 continue reading

Markets, Standardization and OOXML

In my PhD when I was looking for a topic at the beginning I only new that I would like to do something on standardisation and innovation. So I’ve checked many sources, how the Standard Setting Organizations (SSO) work, and as this was last september I was especially interested in how different SSOs deal with the Open Office XML (OOXML) standard.

On my surprise it was the mainly useless website of the Hungarian Standards Office that gave me the idea I am still working on, (and according to my knowledge nobody else did before me). In this post I’ll share with you that bit of information, as it was originally written in Hungarian, this might be of interest for the wider public as well.

 continue reading

Szabványok és Háborúk

Közgazdasági cikkeimet egy népszerű szösszenettel kezdem Shapiro és Varian cikke “A Szabványháborúk” a California Management Reviewban jelent meg, és a szabványosítás nehézségeinek legszellemesebb elemeiből szemezget.

A cikkből például megtudhatjuk, hogy az elektromos széket Edison találta fel azzal a céllal, hogy a vetélytárs váltóáramot (AC) lenyomja. A találmány lényege az volt, hogy AC-ra kötve a székben megsütöttek egy kutyát, ami bizonyítja, hogy a váltóáram veszélyesebb az egyenáramnál.

Ma már persze tudjuk, hogy házi használatra a váltóáram bizonyult jobbnak, és a cikkből azt is megtudhatjuk, hogy Edison végül miért nem költötte el minden pénzét a váltóáram elleni harcra.

A fenti történeten túl más szórakoztató és tanulságos történetekben is bővelkedik a cikk, mindezt színvonalas közgazdasági elemzéssel körítve. Mindenkinek ajánlom!

Setting up Byteflow

In the past weeks I was playing around with byteflow to prepare my own theme and set it up properly. To have it running was really simple, I only had to take care of the /media/, /static/ and /admin-media/ urls to Alias them properly. Otherwise everything went like charm!

After I’ve looked at its admin panel to learn what can I do. The only big mystery was the textblocks app, but after I’ve found some other useful stuff as well.

 continue reading

Thanks to everyone!

As this is my first post on viktornagy.com I would like to say thank you to all who contributed by presenting the system I’m using. I know that this is a very unwise thing to do, but this is one way to say thanks to all the great developers who contributed code to

 continue reading