Django

    [pinterest clone (33)] MultipleObjectMixin을 통한 Projectapp 구현

    articleapp의 model을 보면 writer만 있는데 어떤 project(게시판)의 글인지도 추가 from django.contrib.auth.models import User from django.db import models # Create your models here. from projectapp.models import Project class Article(models.Model): writer = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='arrticle', null=True) project = models.ForeignKey(Project, on_delete=models.SET_NULL, related_name..

    [pinterest clone (32)] Projectapp 구현

    1. Create / Detail / List View (Update / delete) 2. Success_url to related Project 3. Login_required to CreateView 4. Model : title / description / image / created_at 개발 순서는 MVT 순서로 습관을 들이자. (setting 과 url 설정) 1 projectapp 시작 2 settings.py 3 urls.py 4 projectapp/urls.py 생성 : app_name 지정, view 만들고 라우팅할 urlpattern form app_name = 'projectapp' urlpatterns = [ ] (M: model) 5 models.py : title / desc..

    Django NoReverseMatch Error

    urlpattern 문제라고 생각하고 확한결과 pk설정을 안해줘서 생긴 문제같았다. path('delete/', CommentDeleteView.as_view(), name='delete'), 아래와 같이 바꿔주었다. path('delete/', CommentDeleteView.as_view(), name='delete'),

    OperationalError, no such column

    db.sqlite3 를 삭제하고 makemigrations와 migrate를 다시해주었더니 해결되었다.

    django.core.exceptions.FieldError: Unknown field(s) (content) specified for Comment

    forms.py에 fields로 'content'를 넣어주었음에도 unknown이라고하니 models.py를 체크하였다. Comment class에 content 정의에 오타가 있었다. 1. forms.py -fields에 잘 넣었나확인 2. model 확인

    [pinterest clone (29)] ListView, Pagination 적용

    accountview 같은걸 만들때는 단일 객체만 보면 됐었다. detailview 하면 그 사람의 정보, 그 게시물의 정보 이런식이었는데 최종적으로는 게시판의 형태를 만들어야하니까 여러개의 객체를 다룰 수 있는 그런 view가 필요하다. 여러개의 게시글을 한번에 보여줄 수 있는 방법이 필요하다. 그래서 나오는 것이 List view 이다. (django 기본 제공) basicform class ArticleListView(ListView): model = Article context_object_name = 'article_list' template_name = 'articleapp/list.html' paginate_by = 25 *pagination 이란: page의 객체를 생성한다. html te..

    [pinterest clone (28)] 문제사항 수정

    db에 create_at column이 쌓이지 않고(NULL) 있다. (원래 게시물 만든 날짜가 들어가야함) articleapp/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='ar..

    on_delete=SET_NULL 설정시 ERROR 발생

    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') title = models.CharField(max_length=200, null=True) image = models.ImageField(upload_to='article/', null=False) content = models.TextField(null=True) created_at = models.DateField(auto..

    [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 (26)] Articleapp 화면구성 (MagicGrid)

    MagicGrid를 이용해 화면을 구성한다. github.com/e-oj/Magic-Grid e-oj/Magic-Grid A simple, lightweight Javascript library for dynamic grid layouts. - e-oj/Magic-Grid github.com 1 python manage.py startapp articleapp 2 settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ..