내 코드 :'기업'개체가 어떤 속성 'FIRST_NAME을'이없는
from django.db import models
from django.db import connection
class Contact(models.Model):
#Retrieving data from a database
# #Create the cursor
cursor = connection.cursor()
#Write the SQL code
sql_string = 'SELECT * FROM contacts_contact'
#Execute the SQL
cursor.execute(sql_string)
#Print more than two: for row in cursor.fetchall: print(row[1])
#Print one record
print("\033[92m View a sample record: \033[93m" + cursor.fetchone()[1] + "\033[0m")
def form():
first_name = models.CharField(
max_length = 255,
)
last_name = models.CharField(
max_length = 255,
)
email = models.EmailField()
file = models.FileField(upload_to='files/')
form()
def __str__(self):
return ' '.join([
self.first_name,
self.last_name,
])
그리고 내 오류 : '기업'개체가 어떤 속성 'FIRST_NAME'
하는 경우가없는 "형태"숙녀의 코드 다른 곳에서는 괜찮습니다.
은 도와주세요
클래스 정의 내에서 명령을 실행하면 안됩니다. – Daniel
코드에 근본적인 결함이 있습니다. 고칠 것이 너무 많습니다. 도움을 청하기 전에 기본 장고 자습서를 먼저 읽어야합니다. https://docs.djangoproject.com/en/dev/intro/tutorial01/ – skzryzg