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: 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: 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

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

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']

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

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

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

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: 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

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:

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

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: 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

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

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

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

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,

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

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

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

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: 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

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

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()

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

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

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. > > >

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 >

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

2019-10-25 Thread Jason Brechin
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 REST fram

Writing to Nested ModelSerializer

2017-03-31 Thread 'Jason Guy' via Django REST framework
e, 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 a Serializer, but I want to understand the real differences with ModelSerializer vs Serializer. Thanks in advance, Jason -- You received this

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 < > django-res.