Django - (10)

이정인·2023년 5월 22일
0

Django_기말

목록 보기
10/11


# model 적용하기

  • 터미널에 아래의 코드 차례대로 입력하기
python manage.py migration
python manage.py migrate

# profileapp / views.py 작성하기

class ProfileCreateView(CreateView):
    model = Profile
    context_object_name = "target_profile"
    form_class = ProfileCreationForm
    success_url = reverse_lazy('accountapp:hello_world')
    template_name = 'profileapp/create.html'


# profileapp / templates / create.html

  • accountapp / templates / create.html 을 위의 경로로 복사해온다.
  • account 가 아닌 profile 에 대한 html 파일이므로 조금 수정해준다.

  • profileapp / urls.py 에 path 추가하기.



# accountapp / templates / accountapp / detail.html

  • 코드 수정하기

  • runserver
    - 로그인 되어있어야함!
    -> MyPage 클릭

    -> 결과

image 파일 첨부했는데에도 불구하고 이미지 파일을 넣지않았다고 하는 문제 발생

enctype="multipart/form-data"

-> 이 코드를 명시해 줘야 이미지가 제대로 전달됨.


profile
둉이닝

0개의 댓글

관련 채용 정보