Answers for "django homepage"

1

django link home page

---urls.py:---
from django.conf.urls.defaults import *

urlpatterns = patterns('myproject.views',
    url(r'^$', 'index', name='index'), #name is important
)

---Templates:---
<a href="{% url 'index' %}">
Posted by: Guest on March-30-2021
0

add page to django

Example (Hope this helps)

1) url.py
path('po/comparison/<int:pk>/', views.po_comparison, name='po_comparison'),

2) view.py
@login_required
def po_comparison(request, pk):

    po = get_object_or_404(PurchaseOrder, pk=pk)
    po_details = PurchaseOrderDetail.objects.filter(po=po).order_by("id")

    return render(request, 'po/comparison.html', {'po': po, 'po_details': po_details})

3) comparison.html
Your HTML Page goes here
Posted by: Guest on August-28-2020

Python Answers by Framework

Browse Popular Code Answers by Language