Starting with Django: Starting the Project


So I want to start writing in a slightly more technical fashion and put down the thoughts and experiences I've been having lately in developing a new website for myself.

Most recently I've been creating my own blog site using a Django framework.

As I've mentioned before, I enjoy writing in Python, it works for me, but I don't like writing JavaScript or CSS. To be honest, I don't even like writing HTML, but understand that is a necessary evil when it comes to websites.

I have tried, and enjoyed, using Flask which is another Python web frame work, but in my experience that is more suited to smaller sites. Django on the other hand is a fully fledged, all in Python web framework that looks to be easier to build bigger sites. Having looked at the job markets for Python recently, Django seems to be more in demand commercially.

Having decided to make this site, I looked around for the best place to start. There were two key tutorials I used. Real Python and Corey Schafer. Both had their advantages and I learned from both of them.

The basic start of a Django website is very easy.

  • Make sure you have python installed
  • Pip install Django
  • django-admin startproject <ProjectName> .
And that's it, you have a functioning (if not efficient) website. It takes less than 5 minutes. Django even builds your basic framework for you.

Now there are other things you should do like creating a virtual environment, but I'm not going into that much technical detail and would assume anyone doing this would be following a more detailed tutorial or know to create one for everything

so the key one here (for python users essentially) is that last point.

django-admin startproject ProjectName .
So what's going on here is that we are running a script (django-admin) and telling it we want to "startproject", we will call it ProjectName (this should be the name of your project, not ProjectName) and we want to put it in the "." directory.. i.e. current directory.

But what does this do?

It creates the basis of your project.

It creates the core files that will allow your project to work. Files that I will go through in more detail in my next blog.

Comments

Popular Posts