- Getting Started
- The Basics
- Models
- Forms
- Views
- Templates
- URLs
- Signals
- Admin
- Serializers
- REST API
- ContentTypes
- Clone this repository
- Make sure to also clone the required git submodules.
git submodule update --init
- Create a branch named <your_email_address>
git branch <your_email_address>
- Commit your code locally in your branch, and your branch only
git commit -m "Task n: <description>"
- Create a virtual environment using python3.8
- Activate it
- Use this virtual environment for subsequent tasks
- Find the requirements file
- Install all the requirements from requirements.txt
- Document any errors you face in pip_errors.txt
- Name the folder 'test_data'
- All the output files should be stored in this folder.
- Take a screenshot of the site
- [Bonus] The screenshot should be sized exactly 1440x900 pixels
- Name the screenshot 'task_5.png'
- Add the screenshot to the output folder [test_data]
- Name of the app:
tournament
- Add the app to the
INSTALLED_APPS
list insettings.py
class Team(models.Model):
country = models.CharField(max_length=3, unique=True)
class Match(models.Model):
date = models.DateField()
class TeamMatch(models.Model):
team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name='team_matches')
match = models.ForeignKey(Match, on_delete=models.CASCADE, related_name='team_matches')
batting_score = models.IntegerField()
batting_wickets = models.IntegerField()
batting_overs = models.IntegerField()
- Create migrations
- Take a screenshot of the command to create migrations and the output and save the screenshot to
test_data
- Migrate all three models
- Take a screenshot of the command to migrate and the output and save the screenshot to
test_data
- Name of the method:
matches_played
- Return type:
int
- Return value: total number of matches played by the team
- Name of the method:
matches_won
- Return type:
int
- Return value: total number of matches won by the team
- Name of the method:
matches_lost
- Return type:
int
- Return value: total number of matches lost by the team
- Create 10 teams
- Create 40 matches where each match is unique
- Make sure that the team matches are associated with the teams and matches created above
- Make sure that the team matches have random scores, wickets and overs
- Download all data for the
tournament
app - Create a fixture named
tournament.json
intest_data
- Return a list of all teams and information about their wins, losses and matches played
- Use the methods created in 10, 11 and 12
- Sample output is shown
[
{
"team": "ABC",
"matches": 4,
"won": 4,
"lost": 0,
"points": 8
},
{
"team": "DEF",
"matches": 4,
"won": 2,
"lost": 2,
"points": 6
},
{
"team": "HIJ",
"matches": 4,
"won": 1,
"lost": 3,
"points": 2
},
{
"team": "KLM",
"matches": 4,
"won": 1,
"lost": 3,
"points": 2
}
]
- Inherit from DetailView
- Use the
Team
model
- Create a html template called
team_list.html
Team | M | W | L | Pts |
---|---|---|---|---|
ABC | 4 | 4 | 0 | 8 |
DEF | 4 | 2 | 2 | 6 |
HIJ | 4 | 1 | 3 | 2 |
KLM | 4 | 1 | 3 | 2 |
- Create a html template called
team_view.html
- Render the output of 18 in this template
- URL:
/teams/
- View: [19]
- Template: [21]
- URL:
/teams/<team_name>/
- View: [20]
- Template: [22]
- matches: total number of matches played
<int>
- won: total number of matches won
<int>
- lost: total number of matches lost
<int>
26. Replace the methods for the Team
model, created in 12, 13, and 14, to use the new fields created in 25.
- The signal should update the
Team
model with the number of matches played, won and lost - Use the methods created in 12, 13, and 14
- Create a staff user
- Login to /admin
- Add a new user with the following details
- Username:
<your_email_address>
- Password:
<password>
- Email:
<your_email_address>
- Username:
- Country
- Matches
- Won
- Lost
- Points
- LIST all existing teams
GET /api/v1/teams/
- CREATE a new team with
POST /api/v1/teams/
- GET team details with
GET /api/v1/teams/<team_name>/
. Use the serializer you built in [34] - LIST all existing matches played by a team `GET /api/v1/teams/matches/'
- LIST all existing match
GET /api/v1/matches/
- CREATE a new match with
POST /api/v1/matches/
- GET match details with
GET /api/v1/matches/<match_id>/
Create a new model called 'AuditLog' that points to every Match
and TeamMatch
object. The purpose of this exercise is to use ContentTypes.