This file contains hidden or 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 django import forms | |
class ImageForm(forms.Form): | |
file = forms.ImageField() | |
class FileForm(forms.Form): | |
file = forms.FileField() |
This file contains hidden or 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 django.contrib import admin | |
from product.forms import EquipmentForm | |
@admin.register(Equipment) | |
class EquipmentAdmin(admin.ModelAdmin): | |
form = EquipmentForm | |
inlines = [ | |
EquipmentGalleryInline, |
This file contains hidden or 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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
from django.contrib.auth.decorators import user_passes_test | |
from django.conf.urls import patterns, include, url | |
from django.views.static import serve | |
from django.conf import settings | |
This file contains hidden or 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
<div class="row"> | |
<div class="info-block col-xs-12 col-sm-6"> | |
1 | |
</div> | |
<div class="info-block col-xs-12 col-sm-6"> | |
2 | |
</div> | |
</div> | |
<div class="row"> | |
<div class="info-block col-xs-12 col-sm-6"> |
This file contains hidden or 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
{% load crispy_forms_field static %} | |
<div> | |
<div id="div_id_{{ field.name }}" class="form-group"> | |
<div class="controls {{ field_class }} js-fileinput-wrapper" data-fileinput="input_{{ field.name }}_clear" data-name="{{ field.name }}"> | |
<div class="fileinput {% if field.value %}fileinput-exists{% else %}fileinput-new{% endif %}" data-provides="fileinput"> | |
<div class="fileinput-preview img-circle" data-trigger="fileinput"> | |
{% if field.value %} | |
<img style="width: 200px;" src="{{ field.value.url }}"> |
This file contains hidden or 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 django.utils.html import escape | |
from porter.models import EntranceRegister | |
import autocomplete_light | |
class EntranceRegisterAutocomplete(autocomplete_light.AutocompleteModelBase): | |
search_fields = [ | |
'^document_number', |
This file contains hidden or 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
class StudentAnswersAdmin(admin.ModelAdmin): | |
def get_readonly_fields(self, request, obj=None): | |
# make all fields readonly | |
readonly_fields = list(set( | |
[field.name for field in self.opts.local_fields] + | |
[field.name for field in self.opts.local_many_to_many] | |
)) | |
if 'is_submitted' in readonly_fields: | |
readonly_fields.remove('is_submitted') |
This file contains hidden or 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
import socket | |
import httplib | |
import urllib2 | |
import logging | |
# Get an instance of a logger | |
logger = logging.getLogger(__name__) | |
def send_request(url): |
This file contains hidden or 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
{% if is_paginated %} | |
<div class="pagination-wrapper"> | |
<ul class="pager"> | |
{% if page_obj.has_previous %} | |
<li><a href="?page={{ page_obj.previous_page_number }}">Anterior</a></li> | |
{% endif %} | |
{% for page in page_numbers %} | |
{% if page %} | |
{% ifequal page page_obj.number %} | |
<li class="disabled"><a href="#">{{ page }}</a></li> |
This file contains hidden or 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
request.build_absolute_uri(user.avatar.url) |