By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,621 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,621 IT Pros & Developers. It's quick & easy.

how to create upload image function for admin?

P: 88
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:
Expand|Select|Wrap|Line Numbers
  1.  
  2. class upload(forms.Form):
  3.     CarBrand = forms.CharField(max_length=100, label="Car Brand")
  4.     CarModel = forms.CharField(max_length=100, label="Car Model")
  5.     CarSpecification= forms.forms.Field(widget = widgets.Textarea, label="Car Specification")
  6.     Photo=forms.ImageField(upload_to="images/")
  7.     BookingPrice = forms.CharField(max_length = 7)
  8.     CarInventory = forms.IntegerField()
  9.  
however, i am not sure how should i code for views.py, i just write simple code like the following:
Expand|Select|Wrap|Line Numbers
  1. def upload(request):
  2.     if request.method == 'POST':
  3.         form =uploadCar(request.POST)
  4.         if form.is_valid():
  5.             # Do form processing here...
  6.             return HttpResponseRedirect('/upload_success/')
  7.     else:
  8.         form = uploadCar()
  9.     return render_to_response('upload.html', {'form': form})
  10.  
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 :)
Nov 8 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.