From the course: Test-Driven Development in Django

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Saving your model

Saving your model

From the course: Test-Driven Development in Django

Start my 1-month free trial

Saving your model

- [Instructor] So now that we have that portion in place, let's go ahead and move over to our views. We need to write the proper code so that if someone is going to pass us some information via the form, that we actually go and create a hash object. So, let's go ahead and import that hash object up at the top. We're going to say from and we want to import .models import capital hash. Great! Got that in place. Since we're also going to be doing some hashing, let's go ahead and import as well, all lowercase hashlib. Remember, this is what helps us to do the proper hashing. So, now, with our home request, it could receive a post request, it could receive a guest request. So, we need to make an if statement here, decide how we want to react. So, let's start first and say if a request.method, and use two equal signs here, if it's equal to a post, in all caps, there's one situation that we're going to want to handle, and then we're going to have a different situation but we don't even…

Contents