This shows that you use the command python and then the path of the file django-admin.py
Then you use the command startproject to create a new project
Next you want to to setup the database
To do this go to your settings.py file located in your wikicamp directory file
engine inside the quotations to sqlite3
the name of the database is your file so in this example the database name is wikicamp.db
to run the server open up a new command prompt and go to the diretory structure of where you have put the project wiki camp
setup the server python manage.py runserver
now you to sync the database with django .
python manage.py syncdb
now you will be asked to choose a username email address and password. As well as the packages being installed
now we need to create some extra files to we can use models
to do this type the command
python manage.py startapp wiki (make sure that your path includes the wikicamp directory
once you have create some extra files you need to right code for your model
this is found in wiki folder in model.py file
class Page(models.Model):
name = models.CharField(max_length=200, primary_key = True)
content = models.TextField(blank=True)
now you need to install your packages go to your settings.py file and at the bottom of the default settings
django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'wikicamp.wiki'
now save the settings.py file
now go to your command prompt and type
python manage.py syncdb
you will get more output showing the file has been synchronised
if you would like to see the database tables that where created you can test this by typing
python manage.py sql wiki
this will output the database query




No comments:
Post a Comment