On Wed, Mar 10, 2021 at 07:43:55AM -0800, 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) 

You can probably do something like:

if not request.accept('application/json'):
        raise SuspiciousOperation("Sorry we only handle JSON")

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20210310210601.GM15054%40fattuba.com.

Reply via email to