Pass an object file from view to template in Django using AjaxHow to combine 2 or more querysets in a Django view?Can I access constants in settings.py from templates in Django?jQuery Ajax File UploadHow to pass an object from one activity to another on AndroidUsing % url ??? % in django templatesAngularJS with Django - Conflicting template tagsPassing a session to a Django template via jQueryHow to call an Ajax view from template?Django - Call a view with forms from inside a templateUse AJAX to update django if-else template
Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?
Where have Brexit voters gone?
Is Jon Snow the last of his House?
number headings
How should I introduce map drawing to my players?
Why aren't space telescopes put in GEO?
Should I disclose a colleague's illness (that I should not know) when others badmouth him
At what point in European history could a government build a printing press given a basic description?
What does this symbol on the box of power supply mean?
Are these reasonable traits for someone with autism?
Where is the logic in castrating fighters?
Where's this lookout in Nova Scotia?
Should one buy new hardware after a system compromise?
Should breaking down something like a door be adjudicated as an attempt to beat its AC and HP, or as an ability check against a set DC?
Why were helmets and other body armour not commonplace in the 1800s?
In general, would I need to season a meat when making a sauce?
Why do Ryanair allow me to book connecting itineraries through a third party, but not through their own website?
Can a person survive on blood in place of water?
Does Nitrogen inside commercial airliner wheels prevent blowouts on touchdown?
Would Jetfuel for a modern jet like an F-16 or a F-35 be producable in the WW2 era?
I unknowingly submitted plagarised work
My employer faked my resume to acquire projects
Python program to take in two strings and print the larger string
What are these arcade games in Ghostbusters 1984?
Pass an object file from view to template in Django using Ajax
How to combine 2 or more querysets in a Django view?Can I access constants in settings.py from templates in Django?jQuery Ajax File UploadHow to pass an object from one activity to another on AndroidUsing % url ??? % in django templatesAngularJS with Django - Conflicting template tagsPassing a session to a Django template via jQueryHow to call an Ajax view from template?Django - Call a view with forms from inside a templateUse AJAX to update django if-else template
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to pass an object file (3d object) from a view to a html template using Ajax.
Here is the basic code in the view:
def guiMesh(request):
if request.method == 'POST':
if request.is_ajax():
obj = pywavefront.Wavefront( "test.obj")
context = 'meshObj': obj
return render(request, 'template.html', context)
here is the code the template
$.ajax({
url : '', // the endpoint,commonly same url
type : "POST", // http method
data : csrfmiddlewaretoken: csrftoken, cooVertex: cooVertex ,
success : function(dataObj)
console.log("dataObj " + dataObj.size)
)
The view side seems working as it does not give any error, but the template side seems not receiving the file correctly. Where am I doing wrong?
Thank you very much for your help!
ajax django object view django-templates
add a comment |
I am trying to pass an object file (3d object) from a view to a html template using Ajax.
Here is the basic code in the view:
def guiMesh(request):
if request.method == 'POST':
if request.is_ajax():
obj = pywavefront.Wavefront( "test.obj")
context = 'meshObj': obj
return render(request, 'template.html', context)
here is the code the template
$.ajax({
url : '', // the endpoint,commonly same url
type : "POST", // http method
data : csrfmiddlewaretoken: csrftoken, cooVertex: cooVertex ,
success : function(dataObj)
console.log("dataObj " + dataObj.size)
)
The view side seems working as it does not give any error, but the template side seems not receiving the file correctly. Where am I doing wrong?
Thank you very much for your help!
ajax django object view django-templates
2
To return object with ajax from view you need a JsonResponse , look in the django docs docs.djangoproject.com/en/2.1/ref/request-response about JsonResponse
– Dimitris Kougioumtzis
Mar 24 at 9:54
add a comment |
I am trying to pass an object file (3d object) from a view to a html template using Ajax.
Here is the basic code in the view:
def guiMesh(request):
if request.method == 'POST':
if request.is_ajax():
obj = pywavefront.Wavefront( "test.obj")
context = 'meshObj': obj
return render(request, 'template.html', context)
here is the code the template
$.ajax({
url : '', // the endpoint,commonly same url
type : "POST", // http method
data : csrfmiddlewaretoken: csrftoken, cooVertex: cooVertex ,
success : function(dataObj)
console.log("dataObj " + dataObj.size)
)
The view side seems working as it does not give any error, but the template side seems not receiving the file correctly. Where am I doing wrong?
Thank you very much for your help!
ajax django object view django-templates
I am trying to pass an object file (3d object) from a view to a html template using Ajax.
Here is the basic code in the view:
def guiMesh(request):
if request.method == 'POST':
if request.is_ajax():
obj = pywavefront.Wavefront( "test.obj")
context = 'meshObj': obj
return render(request, 'template.html', context)
here is the code the template
$.ajax({
url : '', // the endpoint,commonly same url
type : "POST", // http method
data : csrfmiddlewaretoken: csrftoken, cooVertex: cooVertex ,
success : function(dataObj)
console.log("dataObj " + dataObj.size)
)
The view side seems working as it does not give any error, but the template side seems not receiving the file correctly. Where am I doing wrong?
Thank you very much for your help!
ajax django object view django-templates
ajax django object view django-templates
asked Mar 24 at 4:24
Sim81Sim81
501211
501211
2
To return object with ajax from view you need a JsonResponse , look in the django docs docs.djangoproject.com/en/2.1/ref/request-response about JsonResponse
– Dimitris Kougioumtzis
Mar 24 at 9:54
add a comment |
2
To return object with ajax from view you need a JsonResponse , look in the django docs docs.djangoproject.com/en/2.1/ref/request-response about JsonResponse
– Dimitris Kougioumtzis
Mar 24 at 9:54
2
2
To return object with ajax from view you need a JsonResponse , look in the django docs docs.djangoproject.com/en/2.1/ref/request-response about JsonResponse
– Dimitris Kougioumtzis
Mar 24 at 9:54
To return object with ajax from view you need a JsonResponse , look in the django docs docs.djangoproject.com/en/2.1/ref/request-response about JsonResponse
– Dimitris Kougioumtzis
Mar 24 at 9:54
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320716%2fpass-an-object-file-from-view-to-template-in-django-using-ajax%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320716%2fpass-an-object-file-from-view-to-template-in-django-using-ajax%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
To return object with ajax from view you need a JsonResponse , look in the django docs docs.djangoproject.com/en/2.1/ref/request-response about JsonResponse
– Dimitris Kougioumtzis
Mar 24 at 9:54