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
| File "/Users/ss/.virtualenvs/stuff/lib/python2.7/site-packages/django/template/defaulttags.py", line 285, in render | |
| return nodelist.render(context) | |
| File "/Users/ss/.virtualenvs/stuff/lib/python2.7/site-packages/django/template/base.py", line 834, in render | |
| return mark_safe(''.join(bits)) | |
| TypeError: sequence item 5: expected string or Unicode, MagicMock found |
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 Model1(models.Model): | |
| field1 = models.CharField() | |
| field2 = models.BooleanField() | |
| obj2 = models.OneToOneField('Model2', null=True, blank=True) | |
| obj3 = models.OneToOneField('Model3', null=True, blank=True) | |
| class Model2(models.Model): | |
| ... | |
| @classmethod | |
| def get_model1(cls, some_unique_model2_field): |
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
| @property | |
| def foo(self): | |
| try: | |
| return Foo.objects.get(pk=1) | |
| except Foo.DoesNotExist: | |
| return None | |
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 Model1(models.Model): | |
| pass | |
| class Model2(models.Model): | |
| model1 = OneToOneField('Model1') | |
| ==================================== | |
| class myView(UpdateView): | |
| ... |
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.conf import settings | |
| from django.contrib import messages | |
| from django.core.urlresolvers import reverse | |
| from django.db.models import F | |
| from django.http import HttpResponseRedirect | |
| from django.shortcuts import render_to_response | |
| from django.template import RequestContext | |
| from django.utils import timezone | |
| from django.utils.translation import ugettext as _ | |
| from django.views.generic import FormView |
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 SearchView(FormView): | |
| """ | |
| Class that fetches and displays search results | |
| """ | |
| template_name = 'search.html' | |
| form_class = SearchForm | |
| def form_valid(self, form): | |
| """ | |
| Increments the count of the search phrase if it has been made before, |
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
| # Django settings for TweetSearch project. | |
| import os | |
| SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) | |
| DEBUG = True | |
| TEMPLATE_DEBUG = DEBUG | |
| ADMINS = ( | |
| # ('Your Name', 'your_email@example.com'), | |
| ) |
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
| config/ApplicationResources.groovy: | |
| modules = { | |
| application { | |
| resource url:'js/application.js' | |
| } | |
| xyz { | |
| resource url:'js/xyz.js' | |
| } | |
| } |
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
| key_list = [4, 2, 3] | |
| value_list = ["delta", "alpha", "gamma"] | |
| for i in range(len(value_list)): | |
| value_list[i] = str(key_list[i]) + value_list[i] | |
| print value_list[i] | |
| value_list.sort() | |
| key_list.sort() | |
| print [value for value in value_list] | |
| for i in range(len(value_list)): | |
| value_list[i] = value_list[i].replace(str(key_list[i]), "") |
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
| public void mergeSort(int initial[], int start, int end){ | |
| if(start < end){ | |
| int mid = (start + end) / 2; | |
| mergeSort(initial, start, mid); | |
| mergeSort(initial, mid+1, end); | |
| merge(initial, start, mid, end); | |
| } | |
| } | |
| public int[] merge(int initial[], int start, int mid, int end){ |
NewerOlder