Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django import forms
- from django.views.generic.edit import CreateView
- from .models import Place
- from .models import Location, Category, Rating
- class PlaceForm(forms.ModelForm):
- # ТУКА ДЕФИНИРАМ ПОЛЕТАТА ОТ ДРУГИТЕ МОДЕЛИ class Location, class Category и class Rating
- location = forms.ModelChoiceField(queryset=Location.objects.all())
- category = forms.ModelChoiceField(queryset=Category.objects.all())
- rating = forms.ModelChoiceField(queryset=Rating.objects.all())
- class Meta:
- model = Place
- fields = ['name', 'description', 'location', 'category', 'rating']
- class PlaceCreateView(CreateView):
- model = Place
- form_class = PlaceForm
- template_name = 'my_template.html'
- success_url = '/success/'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement