Skip to content

Instantly share code, notes, and snippets.

@nck2
Created October 20, 2017 12:40
Show Gist options
  • Save nck2/77cc5989a6777362a8b6759e20d22894 to your computer and use it in GitHub Desktop.
Save nck2/77cc5989a6777362a8b6759e20d22894 to your computer and use it in GitHub Desktop.
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("파일의 이름이 너무 깁니다. 과목_이름 처럼 파일이름을 바꿔주세요. 예) 수학_홍길동")
templates_ex.html
<div class="col-sm-10">
{% if field.help_text %}<div class="help-block">{{ field.help_text }}</div>{% endif %}
{{ field }}
{% for error in field.errors %}
<div class="alert alert-danger">
{{ error }}
</div>
{% endfor %}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment