Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CreateView(View):
- def get(self, request):
- if request.user.is_authenticated and request.user.is_staff:
- form = EarthCreateForm()
- return render(request, 'actions/register_new_earth.html', {'form': form})
- else:
- return TemplateResponse(request, 'errors/401.html', status=401)
- def post(self, request):
- if request.user.is_authenticated and request.user.is_staff:
- form = CreateForm(request.POST)
- if form.is_valid():
- cd = form.cleaned_data
- print(cd['image'])
- Earth.objects.create(
- owner=cd['owner'], year=cd['year'], cadastral_number=cd['cadastral_number'], area=cd['area'], total=cd['total'],
- price=cd['price'], notes=cd['notes'], image=cd['image'], privilege=cd['privilege'], city=cd['city'],
- property=cd['property']
- )
- return redirect('earth_create_url')
- else:
- return TemplateResponse(request, 'errors/401.html', status=401)
Advertisement
Add Comment
Please, Sign In to add comment