models.py:
from django.db import models
class Car (models.Model):
id = models.AutoField('ID', primary_key=True)
car_mark = models.CharField(max_length=40)
registration_number = models.CharField(max_length=15)
car_color = models.CharField(max_length=25)
from django import forms
CAR_MARK_CHOICES = (
('',''),
('Audi', 'Audi'),
('BMW', 'BMW'),
('Ford', 'Ford'),
('Honda', 'Honda'),
('Mercedes-Benz', 'Mercedes-Benz'),
('Mitsubishi', 'Mitsubishi'),
('Opel', 'Opel'),
('Toyota', 'Toyota'),
)
class Form_Car(forms.Form):
car_mark = forms.CharField(label='Марка автомобиля', widget=forms.Select(choices=CAR_MARK_CHOICES))
registration_number = forms.CharField(label='Регистрационный номер', max_length=15)
car_color = forms.CharField(label='Цвет', max_length=25)
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from forms import Form_Car
from dbapplication.models import Car
import MySQLdb
def administrator_edit_car(request):
form = Form_Car()
for selected_car in Car.objects.get(id=4):
#form = Form_Car(initial={'car_mark': selected_car.car_mark, 'car_color': selected_car.car_color, 'registration_number': selected_car.registration_number})
return render_to_response('admin/edit_car.html', {'form':form})
выдает ошибку Exception Value: ‘str’ object has no attribute ‘car_mark’
Помогите please