Evaluation Goal
This fictional Evaluation shows how the Newcomer Entry to Django would be, after implementing several points mentioned within the Django Product Evaluation.
Installation
- Install Django (includes sqlite3 with python bindings)
Create a Project
$ django project-create eval $ cd eval
Run the Development Server
$ django server-run $ django server-show
Create the Database
within folder "eval"
$ django db-sync -s
Option -s: Create a superuser by default (e.g. user:admin / pass:django)
Create an Application
$ django app-create cars $ django app-install cars
Create a Class: Car
# within /cars/models.py
class Car(models.Model):
manufacturer = models.CharField(maxlength=30)
model = models.CharField(maxlength=30)
modelYear = models.IntegerField()
def __str__(self):
return '%s %s %s' % (self.modelYear, self.manufacturer, self.model)
class Admin:
pass
Evolve the Database
$ django db-sync
Add Instances
Use the Admin to add instances
Create a Class: Owner
class Owner(models.Model): name = models.CharField(maxlength=50) profession = models.CharField(maxlength=50) def __str__(self): return self.name class Admin: pass
Create a Relation: 1:1
class Car:
...
owner = models.ForeignKey(Owner)
Evolve the Database
$ django db-sync
Add Instances and Relations
use the admin to create instances.
Create a Class: Driver
class Driver(models.Model): name = models.CharField(maxlength=50) licenseType = models.CharField(maxlength=30) car = models.ForeignKey(Car) def __str__(self): return self.name class Admin: pass
Create a Relation: 1:N
class Driver(models.Model):
...
car = models.ForeignKey(Car)
Evolve the Database
$ django db-sync
Add Instances and Relations
use the admin to create instances.
Define a Class: Road
class Road(models.Model): name = models.CharField(maxlength=50) length = models.IntegerField() def __str__(self): return self.name class Admin: pass
Create a Relation: M:N
class Car(models.Model): ... roads = models.ManyToManyField('Road')
Evolve the Database
$ django db-sync
Add Instances and Relations
use the admin to create instances.
Deploy to Production Server
...