Discussion:
Render works but url does not change
Derrick Lu
2018-11-16 02:23:15 UTC
Permalink
HI,
I am having trouble with url when rendering to a new page via a button.
The new page renders but the url does not reflect the new page.
Has anyone had that problem before?
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8a745765-e3a8-4929-baae-b51ed922ae2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Joel
2018-11-16 05:51:27 UTC
Permalink
Post details.. The url, your urls.py etc
Post by Derrick Lu
HI,
I am having trouble with url when rendering to a new page via a button.
The new page renders but the url does not reflect the new page.
Has anyone had that problem before?
--
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
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8a745765-e3a8-4929-baae-b51ed922ae2d%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/8a745765-e3a8-4929-baae-b51ed922ae2d%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA%3Diw_8s46%3DSmDWA%3D4jGSuDsaSS-jGFL8OvdqjHpPTPZq%3DKfww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Derrick Lu
2018-11-16 06:56:55 UTC
Permalink
This is my url.py








*app_name = 'springcity'urlpatterns = [ url(r'^$', views.index,
name='index'), url(r'^home/$', views.home, name='home'),
url(r'^portal/$', views.portal, name='portal'),
url(r'^ajax/cutlist/$', views.cutList, name='cutlist'),]*

This is my views.py

































*def home(request): if request.method == "POST": if 'Search' in
request.POST: modelIn = request.POST['mid'] db =
get_object_or_404(PDetails, model=modelIn) form =
calcForm() form.fields["stc"].initial = db.stc
form.fields["ocv"].initial = db.ocv form.fields["mppv"].initial
= db.mppv form.fields["nvtc"].initial = db.nvtc
form.fields["mmppc"].initial = db.mmppc
form.fields["maxov"].initial = db.maxov
form.fields["maxc"].initial = db.maxc args = {
'calcForm': form, } return render(request,
'calculator/portal.html',args) else: if 'MInput' in
request.POST: form = calcForm() args =
{ 'calcForm': form, }
request.method = "GET" return render(request,
'calculator/portal.html',args) else: if request.method ==
"GET": objectlist =
Brand.objects.all().order_by('brand') args = {
'objectlist': objectlist, } return
render(request, 'calculator/home.html',args)*

Then this is my html that I start off with.





















































*{% extends 'calculator/index.html' %}{% block title %} Home {% endblock
%}{% block link %} {% load staticfiles %} <link rel="stylesheet"
href="{% static 'calculator/css/home.css' %}"/> <script
type="text/javascript" src="{% static 'calculator/js/home.js'
%}"></script>{% endblock %}{% block main %} <form action="{% url
'springcity:home' %}" method="POST" enctype="multipart/form-data">
{% csrf_token %} <div class="row center"> <div
class="input-field col s3 offset-s4"> <select
id="brandID"> <option value="">Choose
Company</option> {% for brand in objectlist
%} <option value='{{brand.brand}}'>{{ brand.brand
}}</option> {% endfor %}
</select> <!--<label>Choose Company</label>-->
</div> </div> <div class="row center"> <div
id="modelRow" class="input-field col s3 offset-s4" hidden>
<select name="mid" id="modelID"> <option value="">Choose
Model</option> </select> <!--<label>Choose
Model</label>--> </div> </div> <div class="row
center"> <div class="col s3 offset-s4"> <div
class="button-center"> <button type="submit" class="btn
waves-effect waves-light" name="Search"
id="search">Search</button> </div> </div>
</div> <div class="row center"> <div class="col s3
offset-s4"> <div class="button-center">
<button type="submit" class="btn waves-effect waves-light" name="MInput"
id="manual_input">Manual Input</button> </div>
</div> </div> </form>{% endblock %}*
Post by Joel
Post details.. The url, your urls.py etc
Post by Derrick Lu
HI,
I am having trouble with url when rendering to a new page via a button.
The new page renders but the url does not reflect the new page.
Has anyone had that problem before?
--
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
<javascript:>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8a745765-e3a8-4929-baae-b51ed922ae2d%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/8a745765-e3a8-4929-baae-b51ed922ae2d%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/81642d5b-a48a-45b8-b4ac-81d686b11f56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
2018-11-16 12:50:09 UTC
Permalink
You're rendering templates and returning the response, but if you want the
URL to change, you need to do a redirect.

Right now, you're telling django for button submits, render the portal
template and return the html. There's nothing in it about redirecting to
another URL
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c2a26a14-5ec4-4905-b8cc-3222948d3f5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...