수강이 제한됩니다.
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
from . import views 가 안되요.
File "C:\github\django_my_websit\my_site_prj\urls.py", line 18, in <module> from . import views ImportError: cannot import name 'views' from 'my_site_prj' (C:\github\django_my_websit\my_site_prj\__init__.py) 와 같은 에러가 나는 데요. community를 사용해서 django setting이 제대로 안되어서 발생하는 문제인가요 ? 만약그렇다면 professional를 반듯이 사용해야 하는 상황인 데요. 좀 난감합니다.
- 해결됨파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
질문이 있습니다!
선생님의 강의를 보며 제가 만들어보고싶은 홈페이지를 구성하고 있습니다. 하지만 진행 중에 어려움이 있어 질문 드립니다. *models.py from django.db import models from django.contrib.auth.models import User class Story (models.Model): title = models.CharField(max_length=20, verbose_name='주관기관') image = models.ImageField( upload_to='blog/%Y/%m/%d/', blank=True, verbose_name='이미지') video_link = models.URLField(verbose_name='링크') def __str__(self): return '{}'.format(self.title) *views.py from django.shortcuts import render from .models import Post, Category, Tag, Story from django.views.generic import ListView class StoryList(ListView): model = Story def get_context_data(self, *, object_list=None, **kwargs): context = super(type(self), self).get_context_data(**kwargs) context['story_list'] = Story.objects.all() return context *post_list.html {% for story in story_list %} <div class="storycircle clearfix"> <div class="circle"> <div class="symbol"> <figure> <a class="venobox" data-autoplay="true" data-vbtype="video" data-title="title" href="{{ story.video_link }}" data-gall="myGallery"><img src="{{ story.image.url }}" alt="{{ story.title }}"></a> </figure> </div> <div class="name"> <h4>{{ story.title }}</h4> </div> </div> </div> {% endfor %} 위와 같이 코드를 구성한 결과 admin 페이지에서 정상적으로 작동되는데 html에 불러오질 못합니다. 모가 잘못된걸까요?ㅠㅠ
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
Category object 가 정치 사회 나 일상 생활 등으로 안바뀌어 져요 ㅠㅠ
Home › Blog › Categories The category "Category object (4)" was added successfully. Select category to change Add category Action: --------- Delete selected categories Go 0 of 2 selected Category Category object (4) Category object (3) 2 categories
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
구문오류발생
안녕하십니까 지난번 질문에 대한 답변은 선생님 덕분에 잘 마쳤습니다. 이번 강의를 따라가던 중 그대로 복사한 js파일에서 자꾸 구문 오류가 납니다. 그 외에 브라우저 화면에 출력되는 것은 따로 오류가 보이지는 않습니다. 혹시 이유가 어떤것이며 어떻게 오류를 없애야하는지 궁금합니다. 감사합니다.
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
test.py 오류
test.py 를 하면 raise ValueError("The '%s' attribute has no file associated with it." % self.field.name) ValueError: The 'image' attribute has no file associated with it.위와 같은 에러가 나옵니다.*test.py 참고 from django.test import TestCase, Client from bs4 import BeautifulSoup from .models import Post, Category, Tag from django.utils import timezone from django.contrib.auth.models import User def create_category(name='대외활동', description=''): category, is_created = Category.objects.get_or_create( name=name, description=description, ) category.slug = category.name.replace('', '-').replace('/', '') category.save() return category def create_tag(name='some tag'): tag, is_created = Tag.objects.get_or_create( name=name, ) tag.slug = tag.name.replace('', '-').replace('/', '') tag.save() return tag def create_post(title, organization, author, link, category=None): blog_post = Post.objects.create( category=category, title=title, organization=organization, birthline=timezone.now(), deadline=timezone.now(), link=link, author=author, created=timezone.now(), updated=timezone.now(), ) return blog_post class TestModel(TestCase): def setUp(self): self.client = Client() self.author_000 = User.objects.create( username='westline', password='nopassword') def test_category(self): category = create_category() post_000 = create_post( title='The first post', organization='SK', link='https://www.naver.com', author=self.author_000, category=category, ) self.assertEqual(category.post_set.count(), 1) def test_tag(self): tag_000 = create_tag(name='bad_guy') tag_001 = create_tag(name='america') post_000 = create_post( title='The first post', organization='SK', link='https://www.naver.com', author=self.author_000, ) post_000.tags.add(tag_000) post_000.tags.add(tag_001) post_000.save() post_001 = create_post( title='The second post', organization='Samsung', link='https://www.naver.com', author=self.author_000, ) post_001.tags.add(tag_001) post_001.save() self.assertEqual(post_000.tags.count(), 2) # post는 여러개의 tag를 가질 수 있다. # 하나의 tag는 여러개의 post에 붙을 수 있다 self.assertEqual(tag_001.post_set.count(), 2) self.assertEqual(tag_001.post_set.first(), post_000) # 하나의 tag는 자신으 가진 post들을 불러올 수 있다. self.assertEqual(tag_001.post_set.last(), post_001) def test_post(self): category = create_category() post_000 = create_post( title='The first post', organization='SK', link='https://www.naver.com', author=self.author_000, category=category, ) class TestView(TestCase): def setUp(self): self.client = Client() self.author_000 = User.objects.create( username='westline', password='nopassword') def test_post_list_no_post(self): response = self.client.get('/blog/') self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') title = soup.title self.assertIn(title.text, '대외활동의 모든 것') self.assertEqual(Post.objects.count(), 0) self.assertIn('아직 게시물이 없습니다.', soup.body.text) def test_post_list_with_post(self): post_000 = create_post( title='The first post', organization='SK', link='https://www.naver.com', author=self.author_000, ) post_001 = create_post( title='The second post', organization='SAMSUNG', link='https://www.daum.net', author=self.author_000, ) self.assertGreater(Post.objects.count(), 0) response = self.client.get('/blog/') self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') body = soup.body self.assertNotIn('아직 게시물이 없습니다.', body.text) self.assertIn(post_000.title, body.text)
- 해결됨파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
django.db.utils.IntegrityError: UNIQUE constraint failed: new__blog_category.slug 오류
migrate 할시 django.db.utils.IntegrityError: UNIQUE constraint failed: new__blog_category.slug오류가 뜹니다ㅠㅠ 왜 이러는지 모르겠어요ㅠㅠ *models.py 첨부합니다 class Category(models.Model): name = models.CharField(max_length=20, unique=True) description = models.TextField(blank=True) slug = models.SlugField(unique=True, allow_unicode=True) def __str__(self): return self.name def get_absolute_url(self): return '/blog/category/{}/'.format(self.slug) class Meta: verbose_name_plural = 'categories'
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
models.DateField format 수정
models.DateField 포맷은 YYYY-mm-dd 식으로 바꾸고modles.DateTimeField 포맷을 YYYY-mm-dd Time 식으로 바꾸고싶은데 어떻게 바꿔야 할까요?
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
분명히 그대로 따라하는데 migrations만 시도하면 아래와 같이 뜹니다.
venv 에서 하고 있는데... C:\github\django_sh_website (master -> origin) (venv) λ ls manage.py* my_site_prj/ README.md venv/ C:\github\django_sh_website (master -> origin) (venv) λ python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 10, in main from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 16, in main ) from exc ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
작동은 하는데 테스트에서 failed가 떠요
C:\github\django-leaftha-first-website (master -> origin) (venv) λ python manage.py test Creating test database for alias 'default'... System check identified no issues (0 silenced). .E ====================================================================== ERROR: test_post_list (blog.tests.Testview) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\github\django-leaftha-first-website\blog\tests.py", line 60, in test _post_list self.assertEqual(post_000_read_more_btn['href'], post_000.get_absolute_url( )) TypeError: 'NoneType' object is not subscriptable ---------------------------------------------------------------------- Ran 2 tests in 0.250s FAILED (errors=1) Destroying test database for alias 'default'...
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
python manage.py runserver 친 후에 아래와 같은 문구들이 뜨면서 127.0.0.1:8000으로 가도 안 떠요 ㅠㅠ
Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). September 24, 2019 - 22:31:23 Django version 2.2.5, using settings 'my_site_prj.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. Exception in thread django-main-thread: Traceback (most recent call last): File "C:\github\django_sh_website\venv\lib\site-packages\django\core\servers\basehttp.py", line 45, in get_internal_wsgi_application return import_string(app_path) File "C:\github\django_sh_website\venv\lib\site-packages\django\utils\module_loading.py", line 17, in import_string module = import_module(module_path) File "C:\Users\kimsh\Anaconda3\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'my_site_prj.wsgi' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\kimsh\Anaconda3\lib\threading.py", line 917, in _bootstrap_inner self.run() File "C:\Users\kimsh\Anaconda3\lib\threading.py", line 865, in run self._target(*self._args, **self._kwargs) File "C:\github\django_sh_website\venv\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "C:\github\django_sh_website\venv\lib\site-packages\django\core\management\commands\runserver.py", line 137, in inner_run handler = self.get_handler(*args, **options) File "C:\github\django_sh_website\venv\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler handler = super().get_handler(*args, **options) File "C:\github\django_sh_website\venv\lib\site-packages\django\core\management\commands\runserver.py", line 64, in get_handler return get_internal_wsgi_application() File "C:\github\django_sh_website\venv\lib\site-packages\django\core\servers\basehttp.py", line 50, in get_internal_wsgi_application ) from err django.core.exceptions.ImproperlyConfigured: WSGI application 'my_site_prj.wsgi.application' could not be loaded; Error importing module.
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
콘솔장에 이런 오류가 뜨는데요 왜 그럴까요?
SCRIPT1002: SCRIPT1002: Syntax error popper.min.js (8,1) SCRIPT438: SCRIPT438: Object doesn't support property or method 'popover' custom.js (14,5)
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
css 파일 생성부터 막혔습니다.
css 파일 생성이 없습니다. 혹시 그것도 프리미엄 만 가능한 기능인가요??.. 강제로 만들어도 안된다고오류 떠요
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
필드 오류 발생했습니다.
오류 발생지점 : 게시물 역 으로 하려고 한 부분부터 오류 시작 def get_queryset(self): return Post.objects.order_by('-created' Post_list.html 파일 <!DOCTYPE html><html lang="ko"><head> <meta charset="UTF-8"> <title>Blog</title></head><body><h1>Blog</h1>{% for p in object_list %}<h3>{{ p.title }}</h3><h4>{{ p.credits }} by {{ p.author }}</h4><p>{{ p.content }}</p>{% endfor %}</body></html>
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
Error가 발생하는데 원인을 모르겠습니다.
TemplateDoesNotExist at /admin/blog/post/2/change/ markdownx/widget2.html Request Method: GET Request URL: http://localhost:8000/admin/blog/post/2/change/ Django Version: 2.2.4 Exception Type: TemplateDoesNotExist Exception Value: markdownx/widget2.html Exception Location: C:\ProgramData\Anaconda3\lib\site-packages\django-2.2.4-py3.7.egg\django\template\backends\django.py in reraise, line 84 Python Executable: C:\ProgramData\Anaconda3\python.exe Python Version: 3.7.3 Python Path: ['C:\\Users\\2045623\\Desktop\\django', 'C:\\ProgramData\\Anaconda3\\python37.zip', 'C:\\ProgramData\\Anaconda3\\DLLs', 'C:\\ProgramData\\Anaconda3\\lib', 'C:\\ProgramData\\Anaconda3', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2.4-py3.7.egg', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\sqlparse-0.3.0-py3.7.egg', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django_markdownx-2.0.28-py3.7.egg', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\markdown-3.1.1-py3.7.egg', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\Pythonwin'] Server time: Thu, 19 Sep 2019 11:36:43 +0900 회사에서 보안 관련하여 Package 설치가 되지 않아. 가상환경 설정안하고 그냥 아나콘다에있는 파이선 사용중이며 필요 Package는 파일 다운받아 python setup.py install로 설치합니다. markdownx 설치 및 설정하고 admin에서 post에 들어가려고 하면 err가 발생합니다.
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
이강의와는 상관없는 질문인데
제가 python으로 분석을 하고 결과를 web으로 나타내고 싶은데 보통 dataframe 형태로 결과가 나오는데 이를 django db에 넣는 효과적인 방법이 무었인가요? csv로 저장하고 읽어들인다든지 이런 방법을 써야하나요?
- 파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
gitignore에 있는 my_site_prj/settings_production.py
삭제된 글입니다
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
선생님 질문드립니다!
선생님 안녕하세요? vscode로 개발중에 문제가 생겨서 질문드립니다. 맥터미널에서는 가상환경 (venv37) 의 파이썬 버전(3.7.4)이나 장고 모듈 버전(2.2.5) 인식이 제대로 되는데요, vscode의 터미널에서는 venv37환경 설정했음에도 불구하고 (vscode팔렛트로도 설정하고, conda activate venv37 명령어 사용하였습니다. 명령어 앞에 (venv37)도 잘 떠요!) venv37의 파이썬 버전이(2.2.7)로 인식되고 장고 모듈이 없다고 뜹니다 ㅠ ㅠ.. 무엇이 문제일까요? 지금까지는 맥터미널 사용해서 강의 잘 따라가고 있고, 장고 서버도 잘 동작합니다! 그러면 그냥 무시하고 맥 터미널을 사용해서 계속 강의 진행해도 될까요? 답변주시면 감사하겠습니다! 감사합니다^^
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
선생님 질문이 있어요~
선생님 안녕하세요? 저는 막 강의를 듣기 시작한 맥OS 사용자 입니다^^. 혹시 아나콘다 말고 미니콘다를 설치해도 괜찮을까요? 그리고 파이참 말고 VS code 를 사용해도 괜찮을까요? 답변 주시면 감사하겠습니다! 감사합니다^^~
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
동일하게 적었는데 ERR가 발생하네요. 다시 계속 봐도 어디가 잘못된건지 모르겠습니다.
DoesNotExist at /blog/1/ Post matching query does not exist. Request Method: GET Request URL: http://localhost:8000/blog/1/ Django Version: 2.2.4 Exception Type: DoesNotExist Exception Value: Post matching query does not exist. Exception Location: C:\ProgramData\Anaconda3\lib\site-packages\django-2.2.4-py3.7.egg\django\db\models\query.py in get, line 408 Python Executable: C:\Users\2045623\Desktop\github\django_my_website\venv\Scripts\python.exe Python Version: 3.7.3 Python Path: ['C:\\Users\\2045623\\Desktop\\github\\django_my_website', 'C:\\ProgramData\\Anaconda3\\python37.zip', 'C:\\ProgramData\\Anaconda3\\DLLs', 'C:\\ProgramData\\Anaconda3\\lib', 'C:\\ProgramData\\Anaconda3', 'C:\\Users\\2045623\\Desktop\\github\\django_my_website\\venv', 'C:\\Users\\2045623\\Desktop\\github\\django_my_website\\venv\\lib\\site-packages', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\django-2.2.4-py3.7.egg', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\sqlparse-0.3.0-py3.7.egg', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\Pythonwin'] Server time: Fri, 23 Aug 2019 19:04:48 +0900
- 미해결파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap
bootstrap강의 내용중 마지막까지 지워지지 않는 오류....
붉은 색 박스 안의 내용은 bootstrap_simplex.html:22 GET http://www.google-analytics.com/ga.js net::ERR_BLOCKED_BY_CLIENT 입니다. 뭔가 막혔다는 이야기 같은데요...이건 어떻게 해결 해야 하나요?