Autos CRUD

This assignment is to build a fully working CRUD (Create, Read, Update, and Delete) application to manage automobiles and their makes (i.e. Ford, Hyundai, Toyota, Tata, Audi, etc.).

This application will be based on this folder in the samples repo:

https://github.com/csev/dj4e-samples/tree/master/autos

Do not clone this repository for this assignment. You will make a new project and application in your django_projects folder and use this application as sample code.

This application will be similar to:

https://crud.dj4e.com

The login information is as follows:

Account: dj4e-crud
Password: dj4e_nn_!

The 'nn' is a 2-digit number that by now, you should be able to easily guess.

Making a New Project

Activate any virtual environment you need (if any) and go into your django_projects folder and start a new application in your dj4e project (this project already should have the 'hello' application from a previous assignment).

workon django2  # as needed
cd ~/django_projects/dj4e
python3 manage.py startapp autos

The autos project is the first of several applications we will add to the dj4e project.

Extending the home (i.e. main) page

Since we will build a number of applications in this project, we will use the home application to provide convienent urls to switch between applications.

And you should have a file dj4e/home/templates/home/hello.html that has the text for the top-level page. You can keep the "Hello World" text in the page somewhere.

Add a link to the "/autos" url in dj4e/home/templates/home/hello.html and anything else the autograder needs:

<ul>
<li><a href="/autos">Autos CRUD</a>
<ul>

It is a list because we will be adding more applications in future assignments. :)

Building the Autos Application

The essense of this task is to adapt the code from:

https://github.com/csev/dj4e-samples/tree/master/autos

and make it work in your autos project.

Here are some tasks:

A data model diagram showing Autos and Makes

Make sure to check the autograder for additional markup requirements.

Things that can go wrong

If you ever get a 405 error on a Django page it probably means that you have defined a view class that does not have a get() method. For example if you meant to say this:

class AutoUpdate(LoginRequiredMixin, UpdateView):
    model = Auto
    fields = '__all__'
    success_url = reverse_lazy('autos:all')

But instead you did:

class AutoUpdate(LoginRequiredMixin, View):
    model = Auto
    fields = '__all__'
    success_url = reverse_lazy('autos:all')

(i.e. you extended View instead of UpdateView) - the result is that there is no def get(self, request): in your view. So you get the 405 HTTP status code (invalid method) when you navigate to the URL that forwards to the view.

References