Read the announcement or the release notes.
The biggest new feature in Django 1.4 is support for time zones when handling date/times. When enabled, this Django will store date/times in UTC, use timezone-aware objects internally, and translate them to users’ local timezones for display.
Django 1.4 has dropped support for Python 2.4. Python 2.5 is now the minimum required Python version. Django is tested and supported on Python 2.5, 2.6 and 2.7.
This change should affect only a small number of Django users, as most operating-system vendors today are shipping Python 2.5 or newer as their default version. If you’re still using Python 2.4, however, you’ll need to stick to Django 1.3 until you can upgrade. Per our support policy, Django 1.3 will continue to receive security support until the release of Django 1.5.
Django does not support Python 3.x at this time. At some point before the release of Django 1.4, we plan to publish a document outlining our full timeline for deprecating Python 2.x and moving to Python 3.x.
When you configure your brand new Django project you’ll see in your settings something like:
SITE_ID = 1
That ID refers to the Django “sites” framework. If you plan on using the admin interface make sure that ID exists in the database, otherwise you’ll get an error:
DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.3
Exception Type: DoesNotExist
Site matching query does not exist.
If it doesn’t exist, create it:
>>> from django.contrib.sites.models import Site
>>> site = Site()
>>> site.domain = 'example.com'
>>> site.name = 'My website'
That’s the ID you should use in your settings file:
SITE_ID = 3
I’m happy to announce that my demo Santa’s Media Queries got the 2nd place on October’s Mozilla Dev Derby!! =)
(Read the announcement)
My first big surprise was to see the number of hits the demo was getting, never thought that it could attract so many people. At the time of this writing it has received 1744 views and 35 likes. Never expected that.
My second (and biggest) surprise was to find out that from all the excellent submissions (I mentioned some in a previous post) mine got to be in the top 3. It’s such an honor.
What makes it even more special is the people who chose it. Let’s take a look at the judges:
- Mike Davies, Web developer, @isofarro
- Ryan Grove, YUI engineer at Yahoo!, @yaypie
- Jeff Malkin, President, encoding.com, @jeffmalkin
- Divya Manian, Web opener at Opera, Open Web Vigilante, @divya
- Ethan Marcotte, Web designer, author, @beep
- Lea Verou, Web developer, Co-founder of Fresset LTD., @leaverou
- Chris Wanstrath, Developer, Github co-founder, @defunkt
- Ben Ward, Fron-end developer at twitter, @benward
And the prize is a beautiful laptop messenger bag, something I’ve been checking out on ebay recently, but this one is *way* better than what I intended to buy =)
This is the prize I got for giving a talk at the RubyConf Uruguay, I totally loved it. It has my github nick in it =)
My talk was “Anatomy of a Single-Page Application: Client-side Model-View-Controller“. (Watch it. Spanish audio, slides in english.) For me was a total success, got a lot of great feedback, people approached me after the talk to ask questions and didn’t hear much of contrary opinions to what I said. I do know that how I said it wasn’t much fun for everyone.
I trolled a little. Not much, just enough, and (almost) always with proper justification. I trolled against jQuery, CoffeeScript and PHP. The problem was that I didn’t know there was a CoffeeScript talk right before mine. Duda Dorenelles talk about CoffeeScript, and as I watched his talk I was feeling bad for what I had on my slides.
“Forget about CoffeeScript, be a man!” I think it’s the most controversial line of my talk, but it’s not groundless, and I explained it. I also talked to Duda and he totally understood, he even agreed with me. He is a super cool guy, I hope we can share a beer again sometime.
The organization of the event was excellent, besides some delay in the talks which is totally normal, everything went very smoothly, at least it seemed so. The night before the event they took the speakers to dinner, I didn’t expect that, was a very nice surprise. And as I mentioned before, I got this beautiful present after the talk which was very cool.
I was very anxious and nervous after the talk so I didn’t look at it very well, didn’t realize it had my nick on it. Later, when I was more calm I saw it and really loved it. I’m looking forward to being part of next year’s RubyConf Uruguay.
Next 11th and 12th November is this year’s RubyConf here in Montevideo. This time I’ll be giving a talk about how to apply the MVC pattern on the client-side.
About the event
I enjoyed last year’s conference but the truth is that I couldn’t get much from it. It was intended for people with previous Ruby knowledge and there was little left for the rest of us.
It looks like this year’s schedule covers a wider range of topics and levels. In their website they promoted it as an event to attract developers from different areas, specially Java.
The Java strategy
In my opinion going after Java (and it’s satellite enterprisey languages) developers is a good strategy. It would be hard to convince people from other languages with a solid web foundation like Python or PHP to move to Ruby where you can basically accomplish the same tasks, and what matters most is how well you know the language/framework.
So I think that for Java developers looking to do web it would really make a difference to switch to another language like Python or Ruby.
About my talk
I have prepared many jokes, some flamewars and naked people. That’s a proven formula for success.
October’s Mozilla Dev Derby was about CSS Media Queries.
According to the Mozilla Developer Network documentation:
CSS 3 enhances support for media-dependent style sheets by letting style sheets be more precisely labeled. A media query consists of a media type and at least one expression that limits the style sheets’ scope by using media features, such as width, height, and color. Media queries let the presentation of content be tailored to a specific range of output devices without having to change the content itself.
This means, basically, you can switch style sheets depending on different properties such as the size of the browser window. Is a simple yet powerful feature, but I think the biggest challenge is coming up with something creative using such an unsophisticated feature.
I submitted two demos:
This demo aims to show how properties can be manipulated based on the browser window size. This works by defining different stylesheets for each of the dimensions you want to take actions on. For the demo I created 14 stylesheets, a base one for every widow size and 13 others for 100px, 200px, 300px and so on until 1300px width.
As you resize the window you’ll see changes in the rotation, opacity, background, width and height of the elements.
This was my first approach to Media Queries, nothing complex but it was fun to spice it up a little with transitions.
Using CSS Media Queries this demo detects the size of your browser window and removes members of the family. Marge and Homer are not as alone as they’d like to be.
My second demo was more a design challenge than a code challenge. Given an image of The Simpsons sitting in their famous couch I started removing them one by one with GIMP until only Homer, Marge and Santa’s little helper were left. Brian, a friend, recommended me to add something more, that’s how spiderpig got behind the couch. I was told that it looks like he eats the people
It got over 100 visits in just 24hs, I was impressed.
Some very good demos by other developers in no particular order:
Maybe Michal meant “in” instead of “is” in “Too many fish is the sea”. Check out michal.b‘s other demos, they are great.
I’m already thinking about what I’m going to do for next month’s Derby with canvas. Let’s see what I can come up with.
According to Wikipedia:
In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning. In simple words an algorithm is a step-by-step procedure for calculations.
Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, will proceed through a finite number of well-defined successive states, eventually producing “output” and terminating at a final ending state.
Heuristic refers to experience-based techniques for problem solving, learning, and discovery. Heuristic methods are used to speed up the process of finding a satisfactory solution, where an exhaustive search is impractical. Examples of this method include using a “rule of thumb”, an educated guess, an intuitive judgment, or common sense.
In more precise terms, heuristics are strategies using readily accessible, though loosely applicable, information to control problem solving in human beings and machines.
Both are ways of reaching from point A to point B, but the algorithm is predictable, that is, the steps are predefined and do not change. On the other hand the heuristic is a higher level technique that does not output a result, as the algorithm does, but instead guides you in finding the solution. The final result varies because the heuristic is only a guide on how to look, not on what to find.
From the book Code Complete: A Practical Handbook of Software Construction:
Here is an algorithm for driving to someone’s house: Take highway 167 south to Puyallup. Take the South Hill Mall exit and drive 4.5 miles up the hill. Turn right at the light by the grocery store, and then take the first left. Turn into the driveway of the large tan house on the left, at 714 North Cedar.
Here is a heuristic for getting to someone’s house: Find the last letter we mailed you. Drive to the town in the return address. When you get to town, ask someone where our house is. Everyone knows us—someone will be glad to help you. If you can’t find anyone, call us from a public phone, and we’ll come get you.
This kind of metaphors can be applied at many levels of software development, from architecture to GUI, relieving us from the need of knowing the internals of the system and therefore easing the understanding of the big picture.
Not too often you need to move a method from one class to another, but sometimes you just do. You may be tempted to do something like this:
>>> class A(object):
... def b(self):
>>> class B(object):
>>> B.b = A.b
>>> b = B()
Traceback (most recent call last):
File "", line 1, in
TypeError: unbound method b() must be called with A instance as first argument (got nothing instead)
But as noted, it doesn’t work. In python even functions are objects, and A.b is an instance of your method. What you need is the class itself, the “raw” function:
>>> B.b = A.b.__func__
El siguiente script valida el número de cédula de identidad Uruguaya.
# -*- coding: utf-8 -*-
CI_RE = re.compile(r'\d')
CI_MAGIC_NUMBERS = (4, 3, 6, 7, 8, 9, 2)
_ci = CI_RE.findall(ci)
counter = 0
for key, value in enumerate(_ci[1:]):
counter += int(value) * CI_MAGIC_NUMBERS[key]
counter %= 10
if (10 - counter) % 10 != int(_ci):
if __name__ == '__main__':
Para utilizarlo correrlo de la siguiente forma:
$ python validarci.py 1.23456-1
Ver también: Script Numeros Cedula Uruguay.