This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models.py########################## | |
class SageSource(models.Model): | |
title = models.CharField(max_length=200, verbose_name = "제목") | |
code = models.TextField(blank=False, verbose_name="소스코드") | |
cat= (("1","대수"),('2','해석')) | |
category = models.CharField(verbose_name="분야", max_length=20, default="대수",choices=cat) | |
def __str__(self): | |
return self.title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.contrib.files import append, exists, sed, put | |
from fabric.api import env, local, run, sudo | |
import random | |
import os | |
import json | |
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))#settings 가 있는 폴더 | |
# PROJECT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),'fbtest') | |
# PROJECT_DIR = './fbtest' # settings가 있는 폴더 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model.py | |
created_at=models.DateTimeField(auto_now_add=True,verbose_name="접수일시",help_text="접수일시입니다.") | |
# 제대로 나오는 view | |
def selform_detail(request,pk): | |
post=get_object_or_404(Tselection,pk=pk) | |
return render(request,'tsel/selection_detail.html',{'post':post}) | |
# selection_detail.html - 제대로 나오는 템플릿 : 정확한 시간인 오후 2시 26분이 찍힙니다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
models.py | |
#일부 | |
tfile=models.FileField(verbose_name="제출서류업로드",upload_to="file_for_selection/llfakfwlllwgahvofak5slfkaljfwhgw/%m/%d",help_text=fhelp,validators=[file_name_length]) | |
validators.py | |
from django.forms import ValidationError | |
def file_name_length(value): | |
if len(value)>90: | |
raise ValidationError("파일의 이름이 너무 깁니다. 과목_이름 처럼 파일이름을 바꿔주세요. 예) 수학_홍길동") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 아래 13번째줄을 없애면 AsPre의 모델에 student 항목이 빈채로 저장 | |
# 하지만 13번째줄을 넣으면 첨부한 사진과 같은 오류 발생. | |
# AsPre의 모델에 student 항목을 현재 request의 유저로 저장하기 위해서는 views를 어떻게 해야 하나요? | |
# views.py | |
def preas_detail(request,pk): | |
'''평가항목보이기''' | |
if request.method=="POST": | |
form = AsPreModelForm(request.POST,addr=request.user.profile.address) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models.py | |
class Profile(models.Model): | |
user = models.OneToOneField(settings.AUTH_USER_MODEL) | |
phone_number = models.CharField(max_length=20, verbose_name="전화번호") | |
address = models.CharField(max_length=30, verbose_name="분반") | |
class_number = models.CharField(max_length=8, verbose_name="학번") | |
# views.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models.py | |
class Profile(models.Model): | |
user = models.OneToOneField(settings.AUTH_USER_MODEL) | |
phone_number = models.CharField(max_length=20, verbose_name="전화번호") | |
address = models.CharField(max_length=30, verbose_name="분반") | |
# views.py | |
@login_required | |
def profile(request,userid): | |
User=get_user_model() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 크롤링 주소 : http://stu.sen.go.kr/edusys.jsp?page=sts_m42310 | |
# 서울고등학교의 월간식단을 아래와 같이 크롤링시도 | |
# 응답실패 | |
import requests | |
from bs4 import BeautifulSoup | |
stuurl="http://stu.sen.go.kr/sts_sci_md00_001.ws" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#settings/common.py | |
INSTALLED_APPS = [ | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'sshsapp', | |
'django_crontab', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |