The questions I've had during my learning process.

Id Question Solved at
1 How do you install? Solved
2 How do you start developing? Solved
3 How do you make graphics with Django? Solved
4 Django uses some kind of structure to tell the application where to look for links. How does this hierarchy work? What is actually put into the different files? Solved
5 What is the most basic way to add the url:s to Solved
6 What is the " '^ " thing that can be seen in the URLpatterns? Solved
7 What is the $ sign in the URLpatterns? Solved
8 If I want to embed an iframe to the app can I do it straight into the HTML? Pending
9 Are all of the URLpatterns always put into the file? Pending
10 Is it difficult to change to the production server? Pending
11 How do I really get an external CSS sheet working? Pending
12 How do I connect a new app that I've created under the project folder to the project? Pending
13 What's the development process if I want to create a new website with apps? Something discovered
14 How do you cross query models? For example, If I have a blog app and a books app, how can I show related blog posts in my books app? Pending
15 How do I take the admin interface into use? Solved
16 How do I alter the models I already have? Pending
17 How do I customize what is shown and can be edited in the admin interface? Solved
18 When I want to start developing after some time, how do I start the server and check the page etc? Pending

Saturday, 30 May 2009

How do I take the admin interface into use?

So now I'll be tackling my question nr 15. The admin interface

15. How do I take the admin interface into use? -file

You have to comment out the necessary lines in your file under /djangoproject or whatever your djangoproject is called.

The lines you need are:

In INSTALLED_APPS, uncomment


'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware' 'django.contrib.auth.middleware.AuthenticationMiddleware'

2. Run python syncdb

This creates the database tables you need for the admin interface when you have uncommented the lines above.

If it's the first time you do this, you'll be asked to create a superuser. Do it and remember your password. Otherwise you'll be able to use the password you have created before. I've actually created the super user for another application, I think, but it still works. Weird. Maybe I'll have an answer for why that happens later. Oh, right, it uses the same database now I guess as for the other applications? Ok, whatever.

Now, if you have already created your own models and you want them to show up in your admin interface, you have to add an file under your app folder (for the application that you want the models to show up in the admin interface), it should look something like this for a basic setup:

from django.contrib import admin
from yourproject.yourappname.models import NameOfclass1, NameOfclass2

No comments: