Re: How to use ASYNC in DRF

2022-10-13 Thread Jason
https://github.com/encode/django-rest-framework/discussions/7774 On Thursday, October 6, 2022 at 11:32:23 AM UTC-4 shahr...@gmail.com wrote: > In the Django Rest Framework, how can i use async because Django supports > async. So, how can i use that async in DRF class based view. If you have > d

Re: Response __init__ has an undocumented "exception" argument - what is this used for?

2020-06-06 Thread Jason
Actually, it is documented, but not explicitly easy to find. Pull Request for the issue 319 You can see the results in the documentati

Re: AttributeError: type object 'CustomerListAPIViewSet' has no attribute 'get_extra_actions'

2020-05-10 Thread Jason
You're inheriting from ListAPIView, not ModelViewSet. Those are two entirely different classes, one is for generic views and the other is for a view set. On Sunday, May 10, 2020 at 4:35:57 AM UTC-4, Asaduzzaman Sohel wrote: > > I got an error when I run my Django app on my local pc. > > > Fi

Re: self.request in APIView

2020-01-15 Thread Jason
`create` is the direct handler for any POST requests that come in. So, it needs to have `request` in there, because its a subclass of `django.views.generic.View` View handlers need to implement the parameter contract that Django specifes. This is hit after all post-request middleware has exec

Re: Raw SQL instead of Django ORM.

2020-01-11 Thread Jason
if you google the terms *django raw sql*, the first result is https://docs.djangoproject.com/en/3.0/topics/db/sql/ -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send a

Re: get_serializer_class don't work in GenericViewSet

2019-11-22 Thread Jason
http://www.cdrf.co/3.9/rest_framework.viewsets/GenericViewSet.html#get_serializer_class Note there’s no args or kwargs in the default implementation, but you have them in yours -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsub

Re: How to use the encoder for `values()` so to behave as if it's still using DRF encoder?

2019-11-03 Thread Jason
Nice work! I think this was an explicit decision by Tom back in 2014. Using https://github.com/encode/django-rest-framework/commit/040bfcc09c851bb3dadd60558c78a1f7937e9fbd for reference, you can see DecimalField

OPTIONS "actions" metadata for non-PUT/POST views

2019-10-25 Thread Jason Brechin
st of methods[1] to report on? I'd gladly open an issue and submit a PR to improve this. Thanks, Jason [1] - https://github.com/encode/django-rest-framework/blob/master/rest_framework/metadata.py#L79 -- You received this message because you are subscribed to the Google Groups "Django

Re: Request method mapping is happening after permission check.

2019-10-24 Thread Jason
Good question! the answer lies in dispatch , try: self.initial(request, *args, **kwargs) # Get the appropriate handler method if request.method.lower() in

Re: KeyError at "url" method

2019-09-08 Thread Jason
Are you running with DEBUG=True in settings? That’ll make Django return a full trace back on exceptions. -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email

Re: KeyError at "url" method

2019-09-08 Thread Jason
CreateAPIView doesn’t implement a GET handler. -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. To vi

Re: read only if authenticated, no access otherwise permission scheme

2019-02-24 Thread Jason
Permissions in django/drf are a tricky beast sometimes. But there's some packages available: https://www.django-rest-framework.org/api-guide/permissions/#third-party-packages https://djangopackages.org/grids/g/perms/ Perhaps one of those has something you can use. -- You received this message

Re: Does partial_update updates DB partially?

2019-02-04 Thread Jason
Perhaps you can make a ticket on the drf github repository? -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegrou

Re: REST Calls to Filter Based On Greater Than, Less Than, or Range

2019-01-04 Thread Jason
> > I've tried django-filters and django-rest-framework-filters but neither > work as stated > what do you mean by this? -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from

Re: Custom Mixin for Mulitple Field Object Lookup in Django REST

2018-10-30 Thread Jason
Due to python's method resolution order, you need to have mixins first in the class inheritance order. Specifically class UnitViewSet(MultipleFieldLookupMixin, viewsets.ReadOnlyModelViewset): ... See https://stackoverflow.com/questions/1848474/method-resolution-order-mro-in-new-style-class

Re: Unit Testing Uploading CSV file

2018-10-26 Thread Jason
sounds like your view is a little wrong, because its not returning any response (eg None) On Friday, October 26, 2018 at 6:11:26 AM UTC-4, Alexander Lamas wrote: > > Hi All, > > I've created a DRF Web API application and I've got the following error > when running my unit test. > > *Message: Exp

Re: how to write routers for the modelviewset based view function

2018-10-07 Thread Jason
Are you sure you have a record in the db with machine_code = 60? your model defines that field as a CharField, so using an integer in the URL makes me suspect you're using a primary key, which is very different from the definition of get_queryset -- You received this message because you are s

Re: Different Serializers in ModelViewSet

2018-09-24 Thread Jason
override and re-implement get_serializer_class On Monday, September 24, 2018 at 12:05:21 PM UTC-4, Tobias Reese wrote: > > Is there a way to define different Serializers within a ModelViewSet Mixin

Re: Attribute Error, attached is the views.py file

2018-09-18 Thread Jason
Googling the query *'_NamespacePath' object has no attribute 'sort'* got me to https://stackoverflow.com/questions/47955397/pip3-error-namespacepath-object-has-no-attribute-sort, which was the second item on the list for future reference, knowing how to search for help with a problem by your

Re: localserver using nginx proxy_pass: how can I set the root url to other than localhost

2018-09-16 Thread Jason
Appreciate the clarification! -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googlegroups.com. For more options, visi

Re: Python 3.7

2018-09-16 Thread Jason
If you look at the PR referred above, it is meant to add python 3.7 compatibility. Looking at the diffs, the only real issue is with timedelta, all other changes are with updating testing configuration As far as updating the docs, they're in the repository at https://github.com/encode/django-r

Re: localserver using nginx proxy_pass: how can I set the root url to other than localhost

2018-09-15 Thread Jason
> > If you said no to any of these, then you shouldn’t be using nginx. > I *strongly* disagree with this. you should use apache with mod_wsg or nginx with uwsgi/gunicorn/etc for production, in which having 10, 1000 or a million users is beside the question. -- You received this message beca

Re: How can i change the username, password and email error message of the serialized field(make a custom error message instead of the built-in messages)

2018-09-15 Thread Jason
http://www.django-rest-framework.org/api-guide/validators/#writing-custom-validators You need to write a custom validator -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it,

Re: localserver using nginx proxy_pass: how can I set the root url to other than localhost

2018-09-15 Thread Jason
sounds to me you don't have server_name set up for your nginx. But not sure if this is the relevant place for that, since its not Django/DRF related, but rather nginx configuration. Perhaps stackoverflow would be a better place to ask? -- You received this message because you are subscribed t

Re: Help,Help,Help! ! ! Why Django serialization takes 3 to 30 seconds

2018-09-12 Thread Jason
uh, that is some network latency but not the root cause for long responses. round trip from US to China is in the order of 300ms or less. Check out the table at http://www.verizonenterprise.com/about/network/latency/ and look at latency from NA to Taiwan and Korea. -- You received this mes

Re: Help,Help,Help! ! ! Why Django serialization takes 3 to 30 seconds

2018-09-10 Thread Jason
While serialization is a computationally expensive operation, it is much more likely it is due to infefficient database setup, configuration, indices and unexpected N+1 queries being executed that are the cause of your issue. Use a profiler like django-silk

Re: Customized Views for CRUD actions

2018-09-07 Thread Jason
I think you're mixing pieces, concepts and ideas up due to your unfamilarity. django can do exactly what you want to do. but it does it in different ways, and DRF adds another way to do it. Problem is, you need to separate out the view layer, the transport format and the presentation layer.

Re: Customized Views for CRUD actions

2018-09-06 Thread Jason
that's what the generics and mixins are for -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email

Re: raq sql query in DEF

2018-08-27 Thread Jason
you don't, you write it with django. https://docs.djangoproject.com/en/2.1/topics/db/sql/ -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-

Re: Documenting responses

2018-08-26 Thread Jason
for now. From the looks of it, 3.8 may see improved support > for this. > > > On Sunday, August 26, 2018 at 2:47:27 PM UTC+2, Jason wrote: >> >> have you looked at >> http://www.django-rest-framework.org/topics/documenting-your-api/ >> >> you can add all t

Re: Documenting responses

2018-08-26 Thread Jason
have you looked at http://www.django-rest-framework.org/topics/documenting-your-api/ you can add all that example info to the docstring of a view. Alternatively, there's https://github.com/marcgibbons/django-rest-swagger/ and apiary, which are two options you can use to document your API. --

Re: Feature Suggestions: Use MySerializer.some_field to read validade_data

2018-08-24 Thread Jason
my_var = serializer.validated_data[MySerializer.some_field] in your example above, what exactly is MySerializer.some_field supposed to do? Is it a string for the field name, or is it the value of the field? thing is, you can already do that with serializer.validated_data['field_name'] so

Re: Unit tests

2018-08-22 Thread Jason
Yes, data that's changed/inserted/deleted in a test doesn't affect other tests. That's the whole point of self-contained tests testing is independent of allowed_hosts, you don't need that by default, the test environment creates the db on each test suite run. -- You received this message beca

Re: Error binding parameter 0 - probably unsupported type

2018-08-13 Thread Jason
what does this have to do with django or django rest framework? -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscr...@googl

Re: Custom additional Error Message along with 200 status code

2018-05-09 Thread Jason
that is bad practice, DO NOT SEND 200 STATUS FOR AN ERROR. How are you to know when a request has errored without checking the text? the status code lets you check by number range easily and go from there. In addition, most JS ajax libraries will use the status code to throw errors which are c

Re: Documenting @api_view() methods properly

2018-01-27 Thread Jason
FWIW, I tend to make subclasses of APIView and implement the functionality there -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+

Re: Which is preferred place to write pre_save signal methods in rest_framework?

2018-01-27 Thread Jason
My preference would be to create a signals.py file in the application and put your signal there, for maximum accessibly and ease of location. Signals, despite the appearance, are not asynchronous, and one of the criticisms of usage is that its easy to forget *where* they're applied and defined

Re: Custom url how to send parameters by url

2018-01-24 Thread Jason
Show the URL you're using On Tuesday, January 23, 2018 at 12:23:03 PM UTC-5, Antonio Junior wrote: > > I want to send a phone through the url already test in several ways but I > can not > > View > > class SearchCustomerViewSet(generics.RetrieveUpdateDestroyAPIView): > > permission_classes =

Re: Why was auth re-invented? What was missing in django?

2018-01-19 Thread Jason
Knowing some of the backstory would be nice for me as well However, why this wasn't ported to Django core as a whole? Most likely because it broke things on that side and django-core developers weren't able to integrate while maintaining compatibility with other parts of the project. -- You

Re: DRF Tutorial Object Level Permissions

2018-01-10 Thread Jason
Or use an IDE with completion, since that auto-suggest occurs in Pycharm all the time. Its pretty handy wen dealing with concrete implementations of generic classes -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from

Re: Writing to Nested ModelSerializer

2017-04-02 Thread 'Jason Guy' via Django REST framework
teractive forms. I would assume this will also be the most maintainable approach. Seriously, thanks for the help, Jason On Friday, March 31, 2017 at 8:26:04 PM UTC-4, Xavier Ordoquy wrote: > > Hi, > > Le 31 mars 2017 à 23:43, 'Jason Guy' via Django REST framework < > d

Writing to Nested ModelSerializer

2017-03-31 Thread &#x27;Jason Guy' via Django REST framework
ested depth is 5, the serializer at level1 would have a really complicated create() method. 4) ModelSerializer is nice for simple models like the example, so why would I want to convert it to a Serializer? - I have read Tom mention mention many times to re-write the ModelSerializer as

Re: Upload file and save in database in Django Restful Framework

2016-07-20 Thread Jason
Thanks a lot Jeff. I'll look through it. On Wednesday, July 20, 2016 at 10:34:38 PM UTC+8, Jeff Tchang wrote: > > Perhaps this might help? > > https://django-storages.readthedocs.io/en/latest/backends/database.html > > > On Wed, Jul 20, 2016 at 4:09 AM, jas

Upload file and save in database in Django Restful Framework

2016-07-20 Thread jason
Hi All, Django Restful provides a easy way to upload file into specified folder. I looked through the document but cannot find anything about storing the uploaded file into database. Is there any example of uploading file and save it in database? It seems that the FileField only allows save th