Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
django create an api

Issue

hi there, my application are almost frontend, what I meant by that, similar to json formatter, codePen, jsFiddle and some online graphers. to be more focused, I have specific views, let's say, a markdown editor, that you can type from left, and outlook appearance render to right.

here, it's a bit intricate. For some user cases: in a form, that the user can input raw text into a textarea, and it's markdown supported, therefore, I need to write a button, see in editor, which takes all user's current input text, and open a new tab with the markdown editor. The difficulty of this, is that those raw text do not need to be saved, the user only need to see the rendered effect, but django only works with model.

I thought of many ways:

  • rest framework api view
  • Ajax POST view
  • abstract model

but I failed to make it work.


Code

template

<!-- some code above -->
{% comment %} form.content returns a string {% endcomment %}
{{ form.content }}
<button>see in editor</button>
<!-- some code below -->

javascript

const content = document.querySelector('#id_content');
const button = document.querySelector('button');
button.onclick = () => {
    $.ajax({
        type: "POST", 
        url: "{% url 'some-view-name' %}",
        data: {
            content: content.value,
        }, 
        success: function(url){
            // return the link of markdown editor
            window.open(url);
        }, 
        error: function(res){
            console.log(res);
        },
    })
}

this javascript is just an attempt, which I have no idea how to write the view.


if I got you confused, I am sorry, please look at: Web: how to redirect to a CodePen or JsFiddle with information filled?, this kind is exactly what I am trying to do, an api backend.

I have been working on the issue for a week, frustrated, I will be very grateful for any of the help you may offer:

  • suggestion of another way
  • any resource to look at
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!