M
M
Michael2017-08-21 22:42:09
Django
Michael, 2017-08-21 22:42:09

Is such an entry safe in the django db?

An ajax request comes the text from the textarea field. Those. js I select the text from the field and send it to the server.

...
axios.post("{% url 'ajax' %}",{
          xsrfHeaderName: "X-CSRFToken",
          data: {
               "text": self.note_t
           },
...

@csrf_exempt
def ajax(request):
    ...
    if request.method == 'POST':
        ...
        note = Notes.objects.get(user=request.user)
        note.text = text
        note.save(update_fields=['text'])
        ...

Is this method of writing to the database safe? In terms of injection, malicious code will not get in?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question