Showing posts with label meta class. Show all posts
Showing posts with label meta class. Show all posts

Wednesday, 27 March 2013

Django: Common Errors, variables not appearing

While it's against the django mindset, I have done a few copy-pastes in my time using this framework.

Recently I've been doing some copy-pasting of some modules and found that often I was getting blank lines when retrieving variables.

The problem was that my text editor was fudging with the tab order of some of the lines-- a huge problem in python-based programs. My Meta class was tabbed forward so it was part of the method, not the class. By de-tabbing it, I was able to see my variables as expected.

Sometimes it's the small things.
If such a scenario exists, a better idea that goes along with the DRY principle would be to create one base Form class with the Meta class and have all other classes inherit it appropriately.