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 django.db.models.expressions import CombinedExpression, F, Value | |
from django.contrib.postgres.fields import JSONField | |
expression = CombinedExpression( | |
F('my_json_field'), | |
'||', | |
Value({'fizz': 'buzz'}, JSONField()) | |
) |
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
r"^([^\.^\?]+[^\/])(\?[^\/.]+)?$" |
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
# | |
# Depends on: puppetlabs/stdlib | |
# | |
define buildsource( | |
$dir = $title, | |
$user = 'root', | |
$path = '/usr/bin:/bin', | |
$timeout = '0', | |
$options = '' | |
) { |
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 CigarList(ListCreateAPIView): | |
""" | |
Lists and creates cigars from the database. | |
""" | |
model = Cigar | |
serializer_class = CigarSerializer |
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 CigarSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = models.Cigar |
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 Cigar(models.Model): | |
name = models.CharField(max_length=25) | |
colour = models.CharField(max_length=30) | |
gauge = models.IntegerField() | |
length = models.IntegerField() | |
price = models.DecimalField(decimal_places=2, max_digits=5) | |
notes = models.TextField() | |
manufacturer = models.ForeignKey('Manufacturer') |
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
os.path.join(os.path.dirname(__file__), 'myfile.txt') |
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
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' | |
SOUTH_TESTS_MIGRATE = False | |
NOSE_ARGS = ['--nocapture', '--nologcapture'] |