
*Brief Explaination*
The first class is the user class, containing the user's username, and which authentication url they are using.
# The database will automatically give each entry a unique id as a primary key (accessed as id or pk)
# Some users use the same username with different authentication urls, so it's important that we specify that the username and authurl are *unique together*
{code}
class Meta:
unique_together=(("username","authurl"))
{code}
The second class is the queries class, we're planning on storing any query the users execute on the web application.
# Again the database will automatically give each entry a unique id as a primary key (accessed as id or pk)
# The important parts to really store are:
## User ID (who used the query)
## URL (which data service)
## Query (the CQL query saved as a Character Field)
## CQL2 (is it a CQL2 query?)
## thekind (what kind of query is it: object only, association etc...)
# The rest of the fields are just to store the query details, so we specified that they can be left blank
# Again user, url and query are *unique together*
{code}
class Meta:
unique_together=(("user","url","query"))
{code}
h3. Step 2: Change the Settings
Even though you've selected the correct database engine back in Part 2. Eclipse will incorrectly prepend the engine name with "django.db.backends"
# Open *GridClient/settings.py*
# Make sure ENGINE is set to the following value:
{code}'ENGINE': 'doj.backends.zxjdbc.postgresql',{code}
# Add thewebapp to the list of INSTALLED_APPS
{code}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'thewebapp',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
{code}
# Add the following setting
{code}
SESSION_SAVE_EVERY_REQUEST = True
{code}
# Save the file
h3. Step 3: Sync with the Database
# Right click the project and select *Django -> Sync DB*
{gallery:include=Screen shot 2011-11-09 at 11.39.23 AM.png}
# On the console you'll see Django syncing with the database, it'll prompt you to make an admin/superuser, go ahead and do that
{noformat}
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no):
{noformat}
# The database is now synced
{scrollbar}