hi
currently i am using Django to create websites, i need to create one function for admin to upload images or photos of the car, since it is a car rental website.
in my carForms.py, the code is like this:
-
-
class upload(forms.Form):
-
CarBrand = forms.CharField(max_length=100, label="Car Brand")
-
CarModel = forms.CharField(max_length=100, label="Car Model")
-
CarSpecification= forms.forms.Field(widget = widgets.Textarea, label="Car Specification")
-
Photo=forms.ImageField(upload_to="images/")
-
BookingPrice = forms.CharField(max_length = 7)
-
CarInventory = forms.IntegerField()
-
however, i am not sure how should i code for views.py, i just write simple code like the following:
-
def upload(request):
-
if request.method == 'POST':
-
form =uploadCar(request.POST)
-
if form.is_valid():
-
# Do form processing here...
-
return HttpResponseRedirect('/upload_success/')
-
else:
-
form = uploadCar()
-
return render_to_response('upload.html', {'form': form})
-
Anyone can help me with this function, the urgent is quite urgent at the moment..thanks in advance for anyone could help me with this :)