Home>
Why such a mistake?
OrderAddView is missing a QuerySet. Define OrderAddView.model, OrderAddView.queryset, or override OrderAddView.get_queryset ().
urls
urlpatterns= [
path ('add /<
str: tag >
', OrderAddView.as_view (), name=' order_add '),
]
view
class OrderAddView (CreateView):
from_class= FastOrdersForm
template_name= 'orders /order_add.html'
def get_context_data (self, *, object_list= None, ** kwargs):
context= super (). get_context_data (** kwargs)
context ['tag']= self.kwargs ['tag']
print ('tag', context ['tag'])
return context
form
class FastOrdersForm (forms.ModelForm):
class Meta:
model= Orders
fields= ['device', 'serial', 'comment', 'status']
widgets= {
'device': forms.TextInput (attrs= {'class': 'form-control'}),
'serial': forms.TextInput (attrs= {'class': 'form-control'}),
'comment': forms.Textarea (attrs= {'class': 'form-control', 'rows': 5}),
}
no, I don't call her anywhere or what?
JopaBoga2021-02-23 15:49:58model= Orders, I only call that model, and it is
JopaBoga2021-02-23 15:53:27hmm ... and not views.OrderAddView.as_view () should be in urlpatterns?
Jack_oS2021-02-23 16:06:37worked, everything was fine, I don't know, I fixed something somewhere
JopaBoga2021-02-23 16:09:26Related questions
- python : Displaying database content on a site with django
- python : Django Select a valid choice. That choice is not one of the available choices when creating a form
- python : Django + tls certificate
- python : Django POST cannot get key
- python : Add file upload form output to DetailView class
- python : Celery adding recurring tasks by users
- python : Find error in template tags
- python : How to make a header like on a template?
- Connecting to ms SQL via python django
do you have an OrderAddView model?
Jack_oS2021-02-23 15:48:35