I've just made my first Django webpage live. It just has some text, shows the date/time and has an admin interface that I can log into. Looking at it, it really doesn't look like much, but today, I got over a hurdle with the framework I've been getting to know for the past few months, and it feels pretty good. I decided to make a post about my experience and what I've learnt of using Django so far.
What the heck is Django?
According to
djangoproject.com:
"Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design."
Sounds quite lovely, doesn't it? A year ago I probably didn't even know what Python was. I'm a Web Designer/Front End Developer, who spent most of the past few years as an all-round Graphic Designer before itching to get back to writing code as well as (and probably more so than) designing things.
HTML and CSS, along with simple, clean, user-focused design are my specialities, and I'm pretty good but still improving with Javascript/Jquery, but I have had some experience with back-end languages. In the past I've dabbled in asp and php along with mysql to do some database-y things, and Visual Basic lessons at college introduced me to some basic programming principles (unintended pun there ;)
So yeah, it's been a long time since I've done much other than HTML/CSS, and when I joined the team I work with currently and found out that our site was built on Django, I really had no idea what that was. But after working closely with back-end developers in recent months, I've got to know Django a lot better.
I work with some really talented people, who all seem to share the opinion "eww php", and promote the DRY (don't repeat yourself ;) philosophy of the Python programming language and Django framework. I'm not getting into a debate about it because I know when it comes to web development there are TONS of different views, but in my opinion, DRY couldn't be a bad thing. Design is great and all, and designs can be beautiful, but code can be equally beautiful. One of the reasons I never tire of writing html and CSS is because I think there's always a challenge there to create beautiful, readable code that makes sense to other people and that is crafted and constructed in the nicest possible way (yes I know HTML & CSS aren't technically code, because people seem to get pedantic about that on the internet, but you know what I mean).
So the whole DRY thing sounded really appealing to me. As an FE developer working in a team using Django, the first part I had to get to know was the template system. I think this alone pretty much made me fall in love with Django :D It feels incredibly simple and nice, the way in which you create base templates and various pages based on them. Previously, in asp/php, I would have used include files for this, which I guess is a similar concept, but I don't know, the Django template system just feels nicer.
Choosing Django for my site
I've needed to set up my own personal site for a good while now, having put most of my effort into work projects lately. As I want to dabble more in back-end stuff as well as front-end, I was wondering which language I should choose. I *could* brush up on php again, after all it's a pretty popular and widely used language. But that didn't seem like a good reason to use it to me, Django seemed more elegant somehow, and I really wanted to use the template system, as well as the nice built-in admin it comes with, which allows you to update the content on your site without having to spend time building a bespoke interface just to do that.
I guess the hardest thing to me was setting up a Django site on my own (not just the templates, while the programmers do the rest). The template code is described as "designer friendly" but the majority of Django is aimed at programmers, as it involves editing/writing Python and using the command line to do most things. I must admit I'm used to installing something by downloading some sort of zipped file and double clicking an "install" icon ;)
So, installing Python and Django with the command line was a challenge on it's own for me. I followed lots of tutorials on the net, but I think that especially with something like this, there is a big gap between copying code that someone is telling you to write and seeing it do something, to *understanding* what the code is doing, why it works, and how you can use it to make your bespoke project. And sure, the command line basics aren't by nature that difficult but you I'd had my head in Photoshop and InDesign for years, and I didn't even know how to navigate my way around files in the terminal.
After installing Django locally, I had a lot of fun trying to get a simple app or page working :) I wouldn't say that it's difficult as such, just.. Python-y, and I guess for me there was a lot of new stuff to understand. I tried a lot of tutorials online, but generally they'd be making sense and then I'd get to one point and go "WTF?" or just suddenly lose the flow and be really confused. You really only need to edit a few Python files to set up a django site, so it is a fairly simple process, but not understanding the lines of Python and being confused about certain things made it all seem very tricky at times.
After getting something straight forward working locally, I decided to just go ahead and get some hosting so I could get something running there and get on and make my site. I went with
webfaction.com for my hosting, as I heard they had a simple one-click installer for setting up a Django site. This did really make it a lot simpler than when I tried to set it up locally even, but I'm glad I had a go at doing that too.
Even after getting the basic app set up, I got confused about making a view and setting up my templates. If you look at the Django documentation it runs through models, the API and views before even getting to templates, so yeah, there was still stuff to get a hold on before I could really dive into the template fun. x_x
What I've learnt so far
So yeah, finally I have a basic page set up, and as I said at the beginning - it doesn't look like much, but I think (for a web designer ;) I've learnt a lot so far!
- I can now use the command line to ssh into my web hosting, navigate folders, create folders and files and edit them (I've been using
nano which was installed by default on my mac), as well as restart the apache server, and sync the database.
- I understand the main Python files that you need to edit to use Django, a lot better. (settings.py, urls.py and views.py). I know what settings to edit in order to make the site work, look at the database and enable the admin.
- I understand how to configure a URL for a view
- I've set up some database fields, displayed the values from these on a page, and managed them using admin (I did this in an earlier tutorial, so I need to revisit it, but again, I think I have a good understanding of how to).
Most of all, I think I have a pretty good idea now of what to do to set up my own blog for example, and I feel pretty proud of that, and also excited to use Django more. I haven't spent long on the design/actual site yet because.. well I know how to do all that pretty much, but my aim was to understand how I could use Django to do it, and I think I've got over my "stuck" hurdles now ;)
To summarise, I think that Django is a bit trickier to get into for a web designer, than say PHP, but so far it seems a really elegant and nice framework, and I would really recommend the template system to web designers. I'm looking forward to developing my site now, and I'll probably update more about how it goes.
Thanks for reading! :)