Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 how retrieve database save multiple data in web Django 2.1
i'm making a web site for post data from my database have many data fields. i can retrieve one data from database.but when trying to get multiple data to retrieve in web page i got errors.
i using django 2.1

Help me to how get multiple data from database and retrieve in webpage
from django.shortcuts import render
from .models import data

# Create your views here.
def index(request):
    return render(request, 'index.html')

def about(request):
    return render(request, 'about.html')

def postjob(request):

        obj = data.objects.all()
        for i in obj:
            print("i :", i)
            context = {
                "title": i.title,
                "jobType": i.jobType,
                "des": i.description,
                "jImg": i.jImg
            print("context:", context)
        return render('jobpost.html', context)
from django.db import models

# Create your models here.
class data(models.Model):
    title = models.TextField()
    jobType = models.TextField()
    description = models.TextField()
    jImg = models.ImageField(upload_to="media")
"""webDiligent URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
from django.contrib import admin
from django.urls import path
from diligent.views import index, about, postjob
from webDiligent import settings
from django.contrib.staticfiles.urls import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

urlpatterns = [
    path('', index, name='index'),
    path('about/', about, name='about'),
    path('jobpost/', postjob, name='postjob'),

urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

<div class="row">
					{% for con in context %}
					<!-- single product -->
					<div class="col-lg-4 col-md-6">
						<div class="single-product">

							<img class="img-fluid" src="{{jImg.url}}" alt="">

							<div class="product-details">
								<div class="price">
								<div class="prd-bottom"><a href="submitcv.html">Send Your CV</a></div>
					{% endfor %}

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Django - Retrieve form data justantest 0 353 May-23-2019, 11:47 AM
Last Post: justantest
  Read Save RadioButtons from Database in Python Flask Webpage Gary8877 0 868 Apr-11-2019, 12:33 AM
Last Post: Gary8877
  Django- Remove leading zeros in values from database ntuttle 1 494 Mar-07-2019, 07:30 PM
Last Post: nilamo
  How to retrieve data from site ROHK 2 392 Mar-01-2019, 12:26 PM
Last Post: ROHK
  how i save the html form to flask database mebaysan 1 1,015 Feb-07-2019, 12:56 AM
Last Post: snippsat
  Django- which database i should use? with best speed and performance!! ma_norouzifar 4 710 Dec-10-2018, 09:47 AM
Last Post: ma_norouzifar
  How to save uploaded image url in database from Django? PrateekG 14 4,578 Jul-04-2018, 05:18 PM
Last Post: PrateekG
  Need your help to fix my database relationship in Django model PrateekG 0 959 Jul-02-2018, 11:08 AM
Last Post: PrateekG
  Why some Django fields are not saved in database? PrateekG 0 675 Jun-21-2018, 08:32 AM
Last Post: PrateekG
  Django - Passing data from view for use client side with JavaScript in a template bountyhuntr 0 1,140 Jun-11-2018, 06:04 AM
Last Post: bountyhuntr

Forum Jump:

Users browsing this thread: 1 Guest(s)