A
A
alexkomp2019-07-18 21:50:27
Django
alexkomp, 2019-07-18 21:50:27

How can I make it so that the user can add posts through a form on the site, and not through the Django admin panel?

How can I make it so that the user can add posts through a form on the site, and not through the Django admin panel?
there is this model:

class Product(ModelForm):
    title = models.CharField(max_length = 130)
    slug = models.SlugField()
    description = models.TextField()
    prise = models.DecimalField(max_digits = 7, decimal_places=0)
    available = models.BooleanField(default=True)
    
    
    def __str__(self):
        return self.title

and form:
class ProductForm(ModelForm):
    class Meta:
         model = Product
         fields = ['description', 'prise', 'available', 'title', 'slug']

views.py
class ProductForm(UpdateView): # CreateView ...
    template_name = 'index.html'
    form_class = ProductForm
    model = Product 
    success_url = "/"

I fill out the form, but it is not displayed on the site and in the admin panel

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2019-07-18
@alexkomp

https://tutorial.djangogirls.org/ru/django_forms/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question