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
import os | |
import mimetypes | |
from django.contrib.staticfiles.storage import staticfiles_storage | |
from django.http import Http404, FileResponse | |
def static_file(request, path, content_type=None): | |
if not staticfiles_storage.exists(path): | |
raise Http404() |
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
class AccountsStatisticsDetail(TemplateView): | |
template_name = 'grow/accountsstatistics.html' | |
def get_context_data(self, **kwargs): | |
context = super().get_context_data(**kwargs) | |
username = self.kwargs.get('username') | |
if username: | |
context['username'] = username | |
context['account_stats'] = ( | |
AccountsStatistics.objects |
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
def user_in_group(user, group_id=None, group_id_list=None): | |
if group_id_list is None: | |
group_id_list = set(group_id] | |
if not hasattr(user, 'group_ids'): | |
user.group_ids = set(user.groups.values_list('pk', flat=True)) | |
return user.group_ids.intersection(group_id_list) |
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
################entering some data the first time to my form doesnt work, it gives this error: | |
IntegrityError at /job/add/article/ | |
(1048, "Column 'author_id' cannot be null") | |
Request Method: POST | |
Request URL: http://localhost:8000/job/add/article/ | |
Django Version: 1.4.3 |
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
def run_validators(self, value): | |
if value in validators.EMPTY_VALUES: | |
return | |
errors = [] | |
for v in self.validators: | |
try: | |
v(value) | |
except ValidationError, e: | |
message = None | |
if hasattr(e, 'code'): |
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
{% if user %} | |
<div class="left_column"> | |
{% endif %} | |
{% block content %} | |
{% endblock %} | |
{% if user %} | |
</div> | |
<div class="right_column"> | |
<div class="sidebar_header user_info"> | |
<h2>Welcome.</h2> |