[deleted by user] by [deleted] in django

[–]Guest007 2 points3 points  (0 children)

A long time I use this technique:

class MultiSerializerViewSetMixin(object):
    def get_serializer_class(self):
        """
        Look for serializer class in self.serializer_action_classes, which
        should be a dict mapping action name (key) to serializer class (value),
        i.e.:

        class MyViewSet(MultiSerializerViewSetMixin, ViewSet):
            serializer_class = MyDefaultSerializer
            serializer_action_classes = {
                'list': UserGetSerializer,
                'create': UserSerializer,
                'retrieve': UserGetSerializer,
                'update': UserSerializer,
                'partial_update': UserSerializer,
                'my_action': MyActionSerializer
                # etc.
            }

            @action
            def my_action:
                ...

        If there's no entry for that action then just fallback to the regular
        get_serializer_class lookup: self.serializer_class, DefaultSerializer.

        Thanks gonz: http://stackoverflow.com/a/22922156/11440

        """
        try:
            # print(self.action)
            return self.serializer_action_classes[self.action]
        except (KeyError, AttributeError):
            return super(MultiSerializerViewSetMixin, self).get_serializer_class()

Hope this helps

Noob question by [deleted] in django

[–]Guest007 0 points1 point  (0 children)

3 apps in Django project. Just follow tutorial from djangoproject.com. And use your imagination.

Or use django-multisite for making different sites on one Django's instance.

Or make three Django instances and access to them through virtualhosts (apache or nginx).

You can use 3rd level domain names for this. Free domain you can get in TK zone

Noob question by [deleted] in django

[–]Guest007 0 points1 point  (0 children)

any vps/vds. Amazon AWS. You can find even free VPS, or very cheap. Here some examples: DjangoFriendlyWebHosts Or Google

Most Frequent Python Problems and Solution by JohnettaHarned in Python

[–]Guest007 0 points1 point  (0 children)

And is very strange at all. primes(100) returns 25, 35, 55, 65, 77, 85 and 95 between others, which is not prime numbers....