I just started to learn Django and relatively new to Python.
I'm trying to understand Django's overview here
from django.db import models
class Reporter(models.Model):
full_name = models.CharField(max_length=70)
def __str__(self): # __unicode__ on Python 2
return self.full_name
class Article(models.Model):
pub_date = models.DateField()
headline = models.CharField(max_length=200)
content = models.TextField()
reporter = models.ForeignKey(Reporter)
def __str__(self): # __unicode__ on Python 2
return self.headline
I wonder how could they do something like this:
# Create a new Reporter.
>>> r = Reporter(full_name='John Smith')
and
>>> a = Article(pub_date=date.today(), headline='Django is cool',
... content='Yeah.', reporter=r)
Can somebody point out where are the constructors defined in the example classes above?