You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>>frompolls.modelsimportChoice, Question# Import the model classes we just wrote.>>>Question.objects.all()
>>>fromdjango.utilsimporttimezone>>>q=Question(question_text="What's new?", pub_date=timezone.now())
>>>q.save()
# Now it has an ID.>>>q.id>>>Question.objects.all()
>>>Question.objects.filter(id=1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NB : We use webpack-dev-server to enable livereload for react frontend at : http://localhost:9000
We add following content in ./frontend/templates/frontend/index.html for React devServer :
<!DOCTYPE html><html><head><metacharset="utf-8"><metaname="viewport" content="width=device-width, initial-scale=1"><title>Django REST with React</title><linkrel="icon" type="image/ico" href="/static/frontend/assets/favicon.ico"></head><body><divid="root"><noscript>You need to enable JavaScript to run this app.</noscript><!-- React will load here --></div></body><scriptsrc="/static/frontend/main.js"></script></html>
This html page is used to have the live reload capability when editing the React.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CORS : https://www.padok.fr/en/blog/cors