Jul-07-2020, 04:39 AM
(Jul-07-2020, 03:20 AM)card51shor Wrote: I thought that was the syntax of all views?
Well, think about it. Not all views need to render a template, do they? Examples:
- The response from an API endpoint, which as you know by now will typically be XML or JSON.
- Redirecting to another page. This is usually done by setting the appropriate status code and the
Location
header.Quote:So I shouldn't call render? Why not? What should I do instead?
Quote:Now I have to change the markup to HTML when shown to the user. I'm going to fiddle around with this later tonight. Any tips as I do it?
These two things make me a bit worried. You seem to be averse to reading documentation. For the former, OK you've figured out a solution by now, but the docs do tell you how to create HTTP responses. I'm not a Django user, but looking at the "Part 3: Views and templates" page linked to from here, there's useful information (I found what I wanted under "Write views that actually do something"). For the latter, you've been advised to use a library to do that, so you need to consult its documentation. It's critical that you use documentation, tutorials etc. to figure stuff out - there isn't always going to be someone on this forum, say, who knows the ins and outs of whatever library you're using. I don't know if you're planning on doing development as a job, but even in that case, you'd have to figure stuff out because it wouldn't really be possible to wait an unspecified amount of time to get an answer. Hint: choose libraries that are well documented and maintained!