장고

    [pinterest clone (27)] articleapp 구현

    1 models.py from django.contrib.auth.models import User from django.db import models # Create your models here. class Article(models.Model): writer = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='arrticle', null=True) title = models.CharField(max_length=200, null=True) image = models.ImageField(upload_to='article/', null=False) content = models.TextField(null=True) created_at ..

    [pinterest clone (22)] ModelForm

    Profileapp을 만들기 시작한다. Account와 Profile을 1:1 로 매칭. 1개의 account는 1개의 profile을 가진다. 구성: Profile Image Profile Nickname Profile Message Delete View는 만들지 않을것이고, Detail View도 profile을 따로 보여주는 페이지를 안만들거니까 구현하지 않는다. 1 python manage.py startapp profileapp 2 settings.py에 추가 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.c..

    [pinterest clone (21)] superuser, media 관련설정

    superuser 생성 : python manage.py createsuperuser media 설정 account app 다음으로 profile app을 만들건데 이미지도 넣을 거기 때문에 이미지 필드를 모델에 설정해줄거다. settings.py에 URL 설정 추가 MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL 설정은 : 127.0.0.1:8000/media/test.jpg 이런걸 바라고 하는거고 MEDIA_ROOT는 : 파일을 올리게되면 platypus에서 media라는 디렉토리가 새로생기면서 올린파일들이 다 저장된다. 장고에서 이미지를 관리할때 쓰는 라이브러리: pillow 설치: pip install pil..

    [pinterest clone (17)] UpdateView를 이용한 비밀번호 변경 구현

    create랑 유사하다. 우선 create 그대로 가져와서 조금만 수정하는식으로. views.py class AccountUpdateView(UpdateView): model = User form_class = UserCreationForm success_url = reverse_lazy('accountapp:hello_world') template_name = 'accountapp/update.html' urls.py from django.contrib.auth.views import LoginView, LogoutView from django.urls import path from accountapp.views import hello_world, AccountCreateView, AccountDeta..

    [Django Tutorial] Blog 만들기 (11)

    Webpack 을 이용해 3개 페이지 만들기 (home.html, post_list.html, post_detail.html) 보통 webpack은 최종결과물로 1개의 html을 생성함. 예로 앞서 dist아래 1개의html을 생성했었다. 여러개 html을 생성하고 싶다면 vue.config.js 에서 pages라는 설정항목을 사용한다. 1 module.exports = { transpileDependencies: [ 'vuetify' ], outputDir: 'dist', publicPath: '/', assetsDir: 'static', pages: { home: { template: 'public/index.html', entry: 'src/pages/main_home.js', filename: '..