Questions tagged [Django Rest Framework] (1)

0
answer

How to organize a SPA authentication when using Django REST framework SessionAuthentication and?

Is: API in DRF, SessionAuthentication. Can't understand how to properly and safely organize a user authentication in a SPA, if a login form is being rendered in SPA. When you use sessions for security, you must use the csrf token. For example, in the case of conventional multi-application on Django uses the standard django ...
dorthy_Aufderhar asked April 19th 20 at 12:33
1
answer

Django REST — How to show every 5th item from the filtered queryset?

Good day. I have now derived all the filtered data from the database. And need to display only every 5th item. How to do it? Thank you. My code serializers.py class CoinCostsSerializer(serializers.ModelSerializer): class Meta: fields = ('price', 'timestamp') model = CoinCosts class CoinSerializer(serializers.Mode...
rickie_Hirt asked April 19th 20 at 12:23
1
answer

Use a nested serializer of sobkovice object?

There is such a serializer class VendorManagementUpdateSerializer(serializers.ModelSerializer): ... parent = VendorToFrontSerializer() # parent = serializers.PrimaryKeyRelatedField(queryset=Vendors.objects.all(), required=False, allow_null=True) ... class Meta: model = Vendors fields = (..., ...., 'parent', ) class...
Nathen_Okuneva asked April 18th 20 at 13:31
1
answer

Django Rest Filterset — how to filter including on nested serializer?

Good evening colleagues! Have such code: serializators.py class CoinCostsSerializer(serializers.ModelSerializer): class Meta: fields = ('price', 'timestamp',) model = CoinCosts class CoinSerializer(serializers.ModelSerializer): class Meta: fields = ('symbol', 'crr', 'costs') model = Coins costs = CoinCostsSerialize...
rodolfo42 asked April 18th 20 at 12:51
1
answer

Django Rest. How to make a nested response?

Hi all. Now I have the answer. { "symbol": "ZERO", "costs": "6.1391", "timestamp": "2020-04-08T14:15:55.765835 Z" }, { "symbol": "ZERO", "costs": "6.1892", "timestamp": "2020-04-08T14:15:01.775659 Z" }, { "symbol": "ZERO", "costs": "6.1221", "timestamp": "2020-04-08T14:13:49.217715 Z" }, Te coin is zero (Django fi...
Jeramie_Klein asked April 18th 20 at 12:46
1
answer

Why doesn't validation in the serializer?

Try to check for the uniqueness of the field level validation in serializer and cannot Panait why the validator is not invoked at all. models.py class Vendor(models.Model): active = models.BooleanField(default=False) ... class VendorContacts(models.Model): vendor = models.ForeignKey('Vendors', related_name='contacts', o...
Colby91 asked April 16th 20 at 10:46
0
answer

ImportError: Failed to import test module, how to solve?

When you start docker-compose run --rm app sh-c "python manage.py test && flake8" gives error Starting recipe-app-api_db_1 ... done System check identified no issues (0 silenced). EEEE ====================================================================== ERROR: app.app (unittest.loader._FailedTest) --------------...
myrl58 asked April 16th 20 at 10:36
0
answer

DRF: how to fix nested serialization?

I create a page that lists all the existing suppliers (Vendors) and modules that apply to each supplier. Here I need to change the status of the module (make them active or inactive), and if the module does not exist, but you need to make it active, then create it. It looks like this. Vendor1 module1/module2 false/true mod...
hilma_Mitche asked April 16th 20 at 10:01
1
answer

Assessment conceded my decisions during training)?

Actually there are 2 chair (repository) there's Vue, which pulls data from the DRF - https://github.com/Ljil/careerFrontend here is the DRF that this data gives https://github.com/Ljil/careerBackend As long as everything is totally simple, but I would like opinions about how bad it is already? How not to do? you can even ma...
maximillia.Kuhn asked April 9th 20 at 10:49
2
answers

Vue + DRF No 'Access-Control-Allow-Origin' header error that is why when you request via Vue???

Have an API that queries localhost:8000/api/vacancies - displays all jobs list localhost:8000/api/vacancies/3 - displays a specific job runs both in a browser (the output from the DRF) and the Postman Notably, the first request is perfectly fulfilled vue like this: fetch(link, { method: "get" }) .then(response => { r...
carley.McLaughl asked April 9th 20 at 10:49