Before we get into the real meat and potato’s of the website, I think it’s important to put up a “Under Construction” page to the site. This way when people go there, they will see that it’s an actual site and they should tune in later to see the changes. After that, we’ll get into our model and what exactly we want, and need, to accomplish some of our goals.
Lets start by creating an application, and we’re going to call it blog. I think that’s appropriate enough, don’t you?
Type the following command from inside your myproject directory:
django-admin.py startapp blog
You’ll notice after you run this command a directory called “blog” is created. This directory holds the views.py and models.py file, which we will come back to later. But for right now we aren’t going to touch either of those files. What we are going to touch is the settings.py file, so that we can tell Django that we have created a new application for it to use. You really don’t have to do this until you’ve created your model, but I am a very forgetful person, and I like to make sure I do as much as possible in advance so I don’t have to worry about it later. So open up your settings.py file and add the following to the bottom of your INSTALLED_APPS section.
‘myproject.blog’,
Your INSTALLED_APPS section should probably look something like the following:
INSTALLED_APPS = (
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.sites’,
‘django.contrib.admin’,
‘myproject.blog’,
)
Now save your settings.py file and run the following command:
python manage.py syncdb
This is going to let the system know you have made some changes. Now is the time we also want to edit they urls.py file, so that we can tell Django which application to run when a particular area of the website is landed on. We are going to add the following line to urls.py.
# For the main page
(r’^$’, include(’myproject.blog.urls’)),
Save the file and then after run:
pkill python
I like to think of this as resetting apache so that it rereads all the configurations. Now don’t go browsing to your website just yet, as if you do you’ll still get an error, because we need to copy the urls.py file in the main area to the blog section. Pay close attention here. I said we will COPY the urls.py file into our application directory. The reason we do this, is so our application becomes more modular, meaning we can manage everything in terms of the application in one place. If you wanted to share your application with someone, it would make it much easier, and allow you to drop them a tar ball of your code and it would be all ready to go. So to get this all in place, issue the following command from inside the myproject directory.
cp urls.py blog/urls.py
So now you should be just about all set. If you understand urls.py enough, you might want to go ahead and take out the stuff in it that isn’t needed. But if your not comfortable with that, then just wait for the next post where we modify this file a little more and create out model, which will allow us to put up that message that says we are under construction.
I know at this point you may feel a little disjointed. We did a bunch of work, but don’t really have anything to show for it. The error message has changed if browse to your site, but that’s really about it. In the next post we’ll put together our model, create a base template which will use the blueprintcss code, and log in to the admin and enter some data. The final result will be a very lightweight page that we can begin to see our work coming together. In the meantime if you have any questions, don’t forget to send me your comments.



























0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
You must log in to post a comment.