Ejemplo n.º 1
0
    def create(self, validated_data):

        involved = validated_data.pop('involved')
        quote = Quote(**validated_data)
        quote.save()

        quote.involved = involved

        return quote
Ejemplo n.º 2
0
    def migrate_quotes(self):
        Quote.objects.all().delete()
        for legacy_quote in LegacyQuote.objects.all():
            assert isinstance(legacy_quote, LegacyQuote)

            date_naive = datetime.utcfromtimestamp(legacy_quote.posted)
            date = timezone.make_aware(date_naive, timezone.utc)

            quote = Quote()
            quote.title = legacy_quote.title
            quote.body = legacy_quote.quote
            quote.created = date
            quote.type = 'internal'

            #quote.image - blob field?

            quote.poster_id = legacy_quote.poster

            quote.save()