16 3 / 2011

Python library to handle photo uploads /resizing

For Housefed, I am looking for a python library / module to allow the user to :

1. Upload an image

2. Resize/crop it to fit 300px X 400px box

3. Save the image

Currently I am using a simple python hack that uploads the image, crops, and ultimately distorts the image. This worked initially to make sure the system works, but I need a more sophisticated system that allows the user to control the image that is saved.

Does anyone know of any python libraries that do this? 

Tags:

Permalink 2 notes

07 3 / 2011

Using Django Comments with a Redirect

One problem I’ve had with Django Comments is redirecting the user after submitting a comment. The default is to render a confirmation page (which seems weird to me). In the Django form, there is a next variable you can define.

Because I’m using the comments for both Photos & Meals in Housefed, I needed a solution for defining next in both cases. If you want to use the default comments app for your site, just use if statements to define the Next variable in each case.

19 2 / 2011

Ask Proudn00b: Adding Fb Connect Oath2 to Django

In preparation for Launch and SxSW, I am integrating Fb Connect to the site. There are two modules you can get pyfacebook & django-facebookconnect that will get you most of the way.

The one bug you’ll run into is how to test the authentication from your local machine. With Facebook, you add your URL in the application settings- that is different from your localhost. To trick it, follow Steve Lacy’s Local development setup for OAuth.

The final piece is adding the right authentication permissions. When the user clicks the connect button, it passes JS:

Does anyone know how to add in the permissions?

09 2 / 2011

Subclasses & the Source Code

Last week I hit a bug I knew I could fix - but I couldn’t. After a day of banging my head against the wall, I came to one conclusion. I needed to reread ‘Learning Python’ to get a better handle on the language.

One of my talents I just recognized is the ability to find patterns. I can see the repetition in Django docs for views or forms, and basically riff off that to hack something together. Its the same with guitar. I can’t write or read music, but I can pick up songs and play those over and over again. The problem is that I didn’t really understand the what & why with Python & Django. I knew what to do, but I didn’t know why or what was going on.

I had to face reality and go back to the basics. I was lacking key pieces of information that weren’t allowing me to solve the problem. Turning back to ‘Learning Python,’ connected many of the dots with OOP- subclasses & overloading methods to be specific. Understanding these pieces led me to understand Django on a whole new level.

A few of you have told me, “Read the Django code” when I send a question your way. For a n00b, this is a daunting proposition. The thought process to a beginner is, “I barely understand my code. What can I possibly get from reading the source code?” To the n00bs out there, the critical piece of information you need to understand is a subclass. Recognizing the methods and attributes of the superclass are what you can access through a subclass is a key connection I hadn’t completely made.

When someone tells you to “Read the code,” it means look to see what are the methods and attributes you inherit from the superclass.

I think making this simple connection has allowed me to turn the page with my coding. Instead of just copying patterns, I am comprehending what is actually going on, and what makes Django such a powerful framework. 

To the n00bs out there, “Understand subclasses, then read the source code.”

23 1 / 2011

Know Django?…Also the new site lets you…

I’m 99% done with the backend for the new site. There is one bug left that drove me to Trader Joes to pick up frozen chicken tikka masala.. I kid you not.

StackOverflow Question: Django-AttributeError

Any Django experts have any ideas?

Thanks guys!

PS I’ll let everyone in on the new site…

Airbnb for meals. I’m a huge Anthony Bourdain fan, and it hit me - How cool would it be to meet people & eat a home-cooked meal?!

So if you are in San Francisco and want to try home-cooked Indian food, you can book a reservation with a cook on the site. Or if you are traveling, find yourself walking the streets of New Delhi, and wonder - “What do the locals eat?” You’ll soon be able to find out!