![]() It shouldn’t surprize you that companies have faced huge financial losses due to poor security, and it has lead to shut down of companies as well. While we should always explicitly inform users before transferring such sensitive data, but we should also make sure we transfer this data as securely as possible. Such sensitive data could be a personal message one user is sending to another, could be an information about the user, could be user’s SMS, so on and so forth. Most of the times, we pass sensitive data from our Android app to our server. Using RSA and AES (Hybrid) encryption technique cleaned_data 25 ) 26 # After the operation was successful, 27 # redirect to some other page 28 return redirect ( '/success/' ) # 4 29 else : # 5 30 # Create an empty form instance 31 form = ContactForm () 32 33 return render ( request, 'contact_form.html', '. is_valid (): # 3 20 # If the form is valid, perform some kind of 21 # operation, for example sending a message 22 send_message ( 23 form. POST ) # 2 18 # Validate the form 19 if form. ![]() method = 'POST' : # 1 16 # Create a form instance with the submitted data 17 form = ContactForm ( request. Textarea ) 11 12 def contact_view ( request ): 13 # The request method 'POST' indicates 14 # that the form was submitted 15 if request. URL shorteners like are another example of where redirects come in handy: you type a short URL into the address bar of your browser and are then redirected to a page with a long, unwieldy URL.ġ from django import forms 2 from django.http import HttpResponseRedirect 3 from django.shortcuts import redirect, render 4 5 def send_message ( name, message ): 6 # Code for actually sending the message goes here 7 8 class ContactForm ( forms. What would an alternative implementation without redirects look like? If a user has to log in to view a page, you could simply display a page that says something like “Click here to log in.” This would work, but it would be inconvenient for the user. When you create an object in the Django admin, Django redirects you to the object list.When you change your password using the Django admin, you are redirected to a page that indicates that the change was successful.When you log in successfully, Django redirects you to the URL you requested originally.When you are not logged-in and request a URL that requires authentication, like the Django admin, Django redirects you to the login page. ![]() To get an idea where redirects make sense, have a look at how Django itself incorporates redirects into features that the framework provides by default: You might wonder why you’d ever want to redirect a user to a different URL in the first place. The simplest way to do this is to use the function redirect() from the module django.shortcuts. In Django, you redirect the user to another URL by returning an instance of HttpResponseRedirect or HttpResponsePermanentRedirect from your view. ![]() This tutorial assumes that you’re familiar with the basic building blocks of a Django application, like views and URL patterns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |