Django Migration "gotcha"

The Model Class used by SomeModel = apps.get_model('some_app', 'SomeModel') is not the model class you wrote.

Consider this example.

Inventory(models.Model):
    quantity = models.IntegerField()

LogEntry(models.Model):
    text = models.TextField()
    created = models.DateTimeField(auto_now_add=True)
    inventory = models.ForeignKey(Inventory, related_name="logs")

    def __unicode__(self):
        return self.text

We want to cache the last logentry as a field on Inventory. Don't ask why, we just do.

We'll change the model like this:

Inventory(models.Model):
    quantity = models.IntegerField()
    last_log_entry = models.TextField()

LogEntry(models.Model):
    text = models.TextField()
    created = models.DateTimeField(auto_now_add=True)
    inventory = models.ForeignKey(Inventory, related_name ...

read more...


Dealing with Django form data for beginners.

I have a continual interest in finding the rough edges of learning Django. Some of the points of form and request handling have been coming up for me recently. What follows is an attempt at some explanation of the difference between request.POST or request.GET and form.cleaned_data of a valid Django Form.

There are two different ways to get the info that you're looking for.

request.POST[somekey] Where somekey is a string representing the associated html <input name="somekey" />.

There is also forms.cleaned_data[somekey] where somekey is the name of the attribute on the ...

read more...


Experimenting with Toga

I heard about Toga from twitter. Apparently it was introduced at PyConAU. I took an hour to whip up a small app that will let you touch buttons to launch fabric tasks.

None of them can take arguments, so it relies on defaults and a fully-stocked set of 'env' variables, but that's ok, this is just a silly hack to explore a new gui framework.

I'll say it's not exceptional in anything other than how easy it was to make the simple app work as advertised.

What I mean is, it seems to have a long way ...

read more...


Snow White, Part Three

Snow White Part 3: Image Manipulation

I'm writing about an interactive art piece I brough to PyOhio and how I built it.

Josh Boles got a (picture)[https://twitter.com/joshboles/status/493466700684091392/photo/1] I like, of the piece while I was talking about something else and the room was playing tetris (More on that soon!)

This post is about the image manipulation.

The piece I built had 20 of the 8 by 8 NeoPixel Matrices to make a canvas. It was arranged like so:

[ 0] [ 1] [ 2] [ 3]
[ 4] [ 5] [ 6] [ 7]
[ 8] [ 9] [10] [11]
[12 ...

read more...



Issac Kelly