i tried everything but this issue persist
here are my code:
view.py:
from ads.models import Ad
from ads.owner import OwnerListView, OwnerDetailView, OwnerCreateView, OwnerUpdateView, OwnerDeleteView
class AdListView(OwnerListView):
model = Ad
class AdDetailView(OwnerDetailView):
model = Ad
class AdCreateView(OwnerCreateView):
model = Ad
fields = ['title', 'text', 'price'] # Include the 'price' field here
class AdUpdateView(OwnerUpdateView):
model = Ad
fields = ['title', 'text', 'price'] # Include the 'price' field here
class AdDeleteView(OwnerDeleteView):
model = Ad
model.py:
from django.db import models
from django.core.validators import MinLengthValidator
from django.contrib.auth.models import User
from django.conf import settings
class Ad(models.Model) :
title = models.CharField(
max_length=200,
validators=[MinLengthValidator(2, "Title must be greater than 2 characters")]
)
price = models.DecimalField(max_digits=7, decimal_places=2, null=True)
text = models.TextField()
owner = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
# Shows up in the admin list
def __str__(self):
return self.title
forms.py:
from django import forms
from .models import Ad
class AdForm(forms.ModelForm):
class Meta:
model = Ad
fields = ['title', 'text', 'price']
ad_form.htm:
{% extends "base_menu.html" %}
{% load crispy_forms_tags %}
{% block content %}
<p>
<form action="" method="post">
{% csrf_token %}
{{ form|crispy }}
<input type="submit" value="Submit">
<input type="submit" value="Cancel" onclick="window.location.href='{% url 'ads:all' %}';return false;">
</form>
</p>
{% endblock %}
please help me fix this issue