Thanks for the reply. However, your answer didn't really solve my issue. The form i mentioned is just an example, in fact i have other views,. The issue is that i want those views to only handle information and send them bach to the front end, but if a user tries to access them through a browser, he either gets redirected to another page or gets an error message.
On Wednesday, March 10, 2021 at 7:44:26 PM UTC Kasper Laudrup wrote: > On 10/03/2021 16.43, Mostapha Bouderka wrote: > > I'm working on a project with react and django; and want to use django > > views to be used as information source only and not show a page on the > > browser. For example, I have a pilot sign up page that uses a pilot > > create view to provide information to the pilot model. I want the users > > to be able to sign up only by using the sign up page, but if someone > > accesses the create pilot view, he shouldn't see anything. > > ( if the url is domain.com/sign-up, he can see the react form ) > > (if the url is domain.com/pilot/create, he shouldn't see anything or > get > > an error, this url should only be used by the react form) > > > > I hope the question is clear and thanks in advance. > > > > If I understand correctly, wouldn't it work simply to look at the > request method for the "domain.com/pilot/create" page and only return a > response in case the method is POST very similar to any other form > handling like this example: > > https://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-view > > but leaving out the else branch and the default return (which would then > make Django return an HTTP 405 error)? > > I don't know anything about React, but from a quick look at the > documentation it like it's just normal HTTP forms using POST. > > Kind regards, > > Kasper Laudrup > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd57c808-7c3e-4dcf-b46f-30a5ab02d8a2n%40googlegroups.com.

