Adding a field to the profile: Difference between revisions

no edit summary
imported>Mark
No edit summary
imported>Mark
No edit summary
Line 149:
$ git commit -a -m "base_profile.html: Now everyone's profile says they were born on January 1, 1980.
</pre></div>
 
=== Edit 2: Adding a field to the Person model ===
 
If you take a look at template you just edited, you will notice that the person's website was referred to as "person.homepage_url". Since you also know that the code we want to edit is most likely in the "profile" module, you should start by looking in models.py, located in the "mysite/profile/" folder.
 
Open models.py and search for "homepage_url". The results of this search should leave you just inside of the Person class. If you look at the surrounding code, you should also notice other familiar fields (take a look back at the template changes you just made), such as irc_nick. Now you should feel confident that this is exactly where you need to add a new field for birthday.
 
At the end of the field definitions, just following the line that adds irc_nick, add a new field for birthday. According to the [https://docs.djangoproject.com/en/dev/ref/models/fields/#datefield Django documentation], you want to use a DateField for storing dates. You will also want to tell the model that it is OK for someone to leave the field blank. You can do that by appending (blank=true) onto the new field.
 
<div class="example"><pre>
birthday = models.DateField(blank=true)
</pre></div>
 
 
=== Inflection point ===
Anonymous user