Django — ‘NoneType’ object has no attribute ‘has_header’

‘NoneType’ object has no attribute ‘has_header’

on if not response.has_header(‘ETag’):

This error appears if you don’t return anything from your view.

return direct_to_template(request, "template")

I wonder if this is a new error message? I recall a more specific error in my previous version of django, something along the lines of “Your view didn’t return anything!”

Django Plugins — Django South for Database Migrations

django-south

Database migrations handled easily. Now I can add the migration files that are generated to the GIT repository PER-BRANCH and grab them on the production server when the time comes.

UPDATE 9 months later when I realized this is one of the top results for django south.

I might as well write a simple tutorial on how to use it. Read the South docs, but in as few lines of code as possible, here’s what to do:

pip install South


### modify settings.py and add 'south' to INSTALLED_APPS


python manage.py syncdb 
# adds south tables


python manage.py schemamigration myapp --initial
# sets up your app for the first migration.


python manage.py migrate myapp --fake 
# "fakes" a migration because you will get an error if you try to migrate
# from an existing database setup. You will get a "table already exists" error otherwise.


### modify your app models, then auto-create a migration


python manage.py schemamigration myapp --auto
# this will auto detect the changes


python manage.py migrate myapp
# will apply new migration.


git add myapp/migrations/ 
# add migrations to version control


### download migrations on remote machine, and simply type in 
python manage.py migrate
# note: this is after faking the first migration if the database exists.

Hope that helps!

Aptana 3 — Python Support / PyDev on Aptana 3 Beta

If you’re running Aptana 3 Beta Windows, PyDev isn’t in the default list of addons via their package installer.

To install it, you just need to add the PyDev site to the installer.

  1. Go to Help > Install New Software
  2. Click “Add”
  3. Fill in PyDev for name, and http://www.pydev.org/updates/ for the location.
  4. Find PyDev by typing Py in the filter text
  5. Check PyDev and be on your way

Git — Change Branch for Uncommitted Working Copy

Say you’re working on branch x and you started to make some changes.

You suddenly realize you meant to be on branch master.

You can’t switch branches w/o committing.

Here’s how to switch:

git stash
git checkout master (or whatever branch you meant to be in)
got stash pop

Resolve the conflicts you get, and you’re good to go.

Jquery — Selectors. Select one child element

Finally, found a reference to my favorite method.

I needed something that traverses the DOM DOWN, not UP, but behaves like $.closest and $.parents

That is: $(TYPE, $JQUERY)

For an image inside a div you’re clicking:

$("div").click(function() { 
   $('img', this).show();  
});

Linode — filesystem is read-only after cloning

Quick tip here for those who just cloned a linode and their newly cloned filesystem says it’s read-only.

As a relative newblet to Sys Admin stuff, I submitted a ticket and got an answer in 30 mins w/ the solution.

Indeed, I did a clone while the source system was online.

The fix

http://library.linode.com/troubleshooting/finnix-recovery

  • Make a new boot configuration in the linode manager.
  • Load the finnix recovery kernel, mount the 3 disks as shown in the image. The finnix partition, your partition, and your swap.
  • Don’t forget the initrd image at the bottom.
  • Boot the system
  • Launch ajax console
  • Type in..
fsck /dev/xvdb
#note: xvdb is the second slot in the mounted disks in your setup. xvdc if you used the third, dvdd if fourth, etc.

and if you don’t want to type yes over and over for a few days, append a -y to it.

fsck /dev/xvdb -y

Reboot your initial configuration, and you’re good to go.

Slicehost to Linode VPS

This is hardly a technical comparison other than citing a benchmark. This is my experience in researching whether I should move from Slicehost to Linode.

The answer I got from my research is that Slicehost appears to be lagging behind due to being acquired by Rackspace. The bottom line though, is real hard data on performance, server hardware, cost per Storage GB, Ram, Bandwidth.

Slicehost acquired by Rackspace: management shift slows down progress.

Slicehost has been very behind these past 2 years — they have made no changes due to their being acquired by Rackspace.

They even admit it in their forums: they are disappointed with where they’ve gone. Lots of talk, no action, etc.

Slicehost admits fault on their forums.

You Guys Really Should…: Start trying to compete again?

When hit with the big question of: “your slices are expensive” their response is that they can scale if you suddenly get a ton of traffic on Christmas eve, which I have no doubt linode can do too.

I’ve read in slicehosts very own forums that many have been switching to linode over the years, including their guru base. I believe it!

In Slicehosts defence:  they claim you pay a premium for their support

But for me, my support has been great on both sides. Starting to claim you pay a premium for the quality, service, etc., is the last pitch you say when you can’t think of any other answers.

I’ve switched my DNS to linode, have used their clone service, resize op,  already submitted a ticket about / got an answer within 30 minutes.

Slicehost has better cloning/resizing, but how often do I use that..?

But to be honest, I don’t care about that too much. I’m not in a position to know how much work they did or didn’t do / what that means for the end consumer.

The bottom line is…

Linode wins performance benchmark of 5 VPS providers.

Check this VPS benchmark for the final answer: http://journal.uggedal.com/vps-performance-comparison

Linode beats the other VPSes on the market. The margin is VERY significant. I’ve already read that Linode simply uses better processors as you can check on your slices vs linodes.

Linode performance /should/ be up considering better processors.

My linode has 4 x Intel Xeon L5520 @ 2.27ghz, 8192kb cache.

Linode: more stuff for your money.

So far, I’m loving that the same $20 buys me 360mb of ram on FASTER servers vs 256mb of ram on slower servers.

  • Linode: $20 – 360mb ram – 16gb storage – 200gb bandwidth
  • Slicehost: $20 – 256mb ram – 10gb storage – 150gb bandwidth

Some straight out of the box features I’ve stumbled upon in linode

  • Web console
  • Major downside of linode was not having clone backups. They added it last month.
  • Private IP for free in-datacenter communication (my backups)
  • Admin with CPU/Traffic/Disk IO graphs for past 24 hrs, 30 days, and archive.
  • Auto reboot
  • One click server deployment scripts (I used one that sets up fail2ban, basic iptables, apache, django_wsgi, postgres / db…)
  • Ability to use different kernels. I used a recovery partition already.
  • Cool SSH access by whitelisted IP only. non whitelisted IP login attempt generates email to you to ask if you want to whitelist it. Simple. Effective.
  • Notifications on cpu/disk/traffic over certain threshold
  • and find the rest yourself! they have money back guarantee and it’s not like it’s expensive.

Here’s a referral link to linode

Assembla / Git — Delete a Repository within Space

Deleting a git / svn repository without deleting the whole space.

I gave up since I couldn’t google the answer.

Deleting repo:

Go to the space specific page, where you see all the repo tabs.

Click Admin tab.

Scroll to “tools”.

Click the “more” link on the right of  “tools”

Delete specific repositories on the right sidebar under “installed tools”

By the way, assembla is a host for Subversion and Git version control. They offer 2gb, FREE and PRIVATE hosting for git.

I highly recommend them.