473,287 Members | 2,682 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

how to create upload image function for admin?

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
0 1248

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

Similar topics

15
by: lawrence | last post by:
I've been using the following function (yes, it is inelegant, what can I say, I wrote it a long time ago) to upload images. Haven't had a problem with it for at least a year, and I don't recall...
1
by: Mark Hanford | last post by:
The Why: I'm in the process of creating a Linux+Apache+PHP website with a public area and an admin area for configuration and updates. The What: One of the features of the admin area is...
0
by: Paul Hamlington | last post by:
Hello, I've been programming in ASP for a little while now and quite an advanced user, but I have come across an unusual problem in which I need assistance. I have built my own image upload,...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
4
by: Jim Michaels | last post by:
after a file upload, $_FILES is not populated but $_POST is. what's going on here? $_POST=C $_POST=C $_POST=C $_POST=C:\\www\\jimm\\images\\bg1.jpg $_FILES= $_FILES= $_FILES=
18
jhardman
by: jhardman | last post by:
Have you ever wanted to upload files through a form and thought, "I'd really like to use ASP, it surely has that capability, but the tutorial I used to learn ASP didn't mention how to do this."? ...
2
by: Amzul | last post by:
hello all i search the net for upload picture secure code i fuond this code, and affter i changed it abit it looks like that : <?php class image_upload { var $tmp_image; var...
1
by: nwclark | last post by:
I am a noobie so pleas bear with me.. I am trying to link a image to a MYSQL variable. I have user photos that i would like to link this page. So far I created an image upload and renamed the...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.