Мне нужно увидеть отображение ввода пользователя на странице администратора django, из того, что я прочитал, мне нужно использовать list_display, но на странице администратора ничего не появляется. Может быть, есть проблема в views.py, но все выглядит хорошо. Вот мой код:
Views.py
def process_e(request):
website_name = request.POST["website_name"]
product_name = request.POST["product_name"]
phone_number = request.POST["phone_number"]
website_details = request.POST["website_details"]
website_content = request.POST["website_content"]
created_objs = Enterprise.objects.create(website_name=website_name, product_name=product_name, phone_number=phone_number, website_details=website_details, website_content=website_content)
legth_of_todos = Enterprise.objects.all().count()
created_items = Enterprise.objects.all()
if request.method == 'POST':
if request.POST.get('website_name') and request.POST.get('product_name') and request.POST.get('phone_number') and request.POST.get('website_details') and request.POST.get('website_content'):
post=Enterprise()
post.title= request.POST.get('website_name')
post.content= request.POST.get('product_name')
post.content= request.POST.get('phone_number')
post.content= request.POST.get('website_details')
post.content= request.POST.get('website_content')
post.save()
return render(request, 'enterprise.html', {"created_items":created_items})
else:
pass
else:
return render(request,'enterprise.html')
Admin.py
from django.contrib import admin
from service.models import Enterprise
class PaymentsAdmin(admin.ModelAdmin):
list_display = ('website_name', 'product_name', 'phone_number', 'website_details',
'website_content')
admin.site.register(Enterprise, PaymentsAdmin)
Models.py
from django.db import models
class Enterprise(models.Model):
website_name = models.CharField(max_length=50)
product_name = models.CharField(max_length=200)
phone_number = models.CharField(max_length=200)
website_details = models.CharField(max_length=200)
website_content = models.CharField(max_length=200)
Html
<div class="form-group">
<label>Website name</label>
<input type="text" name="website_name" class="form-control" placeholder="First name">
</div>
<div class="form-group">
<label>Product name (if there is)</label>
<input type="text" name="product_name" class="form-control" placeholder="First name">
</div>
<div class="form-group">
<label>Phone number</label>
<input type="text" claa="phone_name" class="form-control" placeholder="First name">
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">What kind of content should your website upload?</label>
<textarea class="form-control" name="website_content" rows="3"></textarea>
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1">Website details</label>
<textarea class="form-control" name="website_details" rows="3"></textarea>
</div>