django.fm.IntegerField - python examples

Here are the examples of the python api django.fm.IntegerField taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

0 View Complete Implementation : views.py
Copyright MIT License
Author : othreecodes
@login_required
def vehicle_share(request, user_id, vehicle_id):
    user = get_object_or_404(CustomUser, pk=user_id)

    form = VehicleShare(request.POST or None)
    if request.user != user:
        raise Http404
    if user.user_type == 'Pastenger':
        raise Http404
    ride = Vehicle.objects.get(pk=vehicle_id, user=user)

    if request.method == "POST":
        if form.is_valid():
            share = form.save(commit=False)
            share.user = user

            share.start_time = request.POST['start_time']

            share.vehicle = ride
            share.save()
            rides = Vehicle.objects.filter(user=user).order_by('pk').reverse()
            shared = VehicleSharing.objects.filter(user=user).order_by('date').reverse()
            share = VehicleSharing.objects.filter(user=user).latest('pk')
            notify.send(user, recipient=user, verb='Shared a Ride', level='success', action_object=share,description='Ride Shared Sucessfully', target=ride)
            context = {
                'user': user,
                'rides': rides,
                'shared': shared,
                'message':True,
                'message_heading':'Ride Shared Successfully',
                'message_body':'Your ride has been shared successfully, make sure to end sharing when done.',
            }


            return render(request, 'app/vehicles/view_shared.html', context)


        else:
            form.fields['no_past'] = fm.IntegerField(widget=forms.TextInput(attrs={'max':ride.seats,'type':'number', 'min':"1",'required':True,'clast':'form-control'}))
            form.fields['no_past'].label = 'Number of Pastengers'
            form.fields['cost'] = fm.IntegerField(widget=forms.TextInput(attrs={'type':'number', 'min':"10", 'required':True,'placeholder':'In Naira (₦) ','clast':'form-control'}))

            return render(request, 'app/vehicles/share_ride.html', {'user': user, 'ride': ride, 'form':form})
        past

    else:

        form.fields['no_past'] = fm.IntegerField(widget=forms.TextInput(attrs={'max':ride.seats,'type':'number', 'min':"1",'clast':'form-control'}))
        form.fields['no_past'].label = 'Number of Pastengers'
        form.fields['cost'] = fm.IntegerField(widget=forms.TextInput(attrs={'type':'number', 'min':"10", 'required':True,'placeholder':'In Naira (₦) ','clast':'form-control'}))

        return render(request, 'app/vehicles/share_ride.html', {'user': user, 'ride': ride, 'form':form})