Sep-07-2020, 08:19 PM
(This post was last modified: Sep-07-2020, 08:19 PM by card51shor.)
Yes I'm using Django ORM.
OK so I have it printing out the objects on my Auction page. But it's just the names of the objects and not the actual data. How do I change this? I tried the .values method but it didn't work saying there was no values method.
Here's what I'm seeing on the page:
![[Image: v.php?i=7bca5f3445]](https://www.picpasteplus.com/v.php?i=7bca5f3445)
Code:
views.py :
OK so I have it printing out the objects on my Auction page. But it's just the names of the objects and not the actual data. How do I change this? I tried the .values method but it didn't work saying there was no values method.
Here's what I'm seeing on the page:
Code:
views.py :
def auction(request): if request.method == "POST": title = request.POST.get("title") description = request.POST.get("description") price = request.POST.get("price") category = request.POST.get("category") new = NewPost.objects.create(title = title, description = description, price = price, category = category) new.save() return render(request, "auctions/auction.html") else: query = NewPost.objects.all() print(query) return render(request, "auctions/auction.html", { "queries": query })auction.html :
{% extends "auctions/layout.html" %} {% block body %} <h2>Post Your Item For Sale</h2> <form name="auction" action="/auction" method="post" >{% csrf_token %} <input type="text" name="title" placeholder="Enter Title of Item" required> <input type="textarea" size=100 name="description" placeholder="Enter Description of Item" required> <input type="number" name="price" placeholder="Enter Starting Price" required> <input type="text" name="category" placeholder="Enter Category" required> <input type="submit" id="auction" name="auction" value="Create New Auction" /> </form> {{% for query in queries %} <li><a href="/wiki/{{entry}}">{{ query }}</a></li> {% endfor %} {% endblock %}