Re: Database for Unit Test

2018-08-24 Thread Alex Daigle
I’ve had fairly good success with setting up Django tests with ‘model mommy’, aka ‘mommy’. I highly recommend looking for it and looking around for other similar libraries. It makes setting up and tearing down cases much easier. Sent from my iPhone > On Aug 24, 2018, at 08:00, Marc Chakiachvil

Re: Development and Production environment

2018-08-24 Thread Alex Daigle
Another solution is to have a settings folder, with (inside) a base.py, local.py, debug.py... the base settings that are the same for all your settings. This allows you to be more specific with things like installed apps that you may want in your local development and not in a production environ

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

Feature Suggestions: Use MySerializer.some_field to read validade_data

2018-08-24 Thread Ezequiel Bertti
Hi, I want to suggest a feature on github, but first, I want to ask the group about it. Something like this: class MySerializer(serializers.Serializer): some_field = serializers.IntegerField() def request(request): serializer = MySerializer(data=request.GET) if seria

Re: is it possible to use both oauth2 toolkit and another auth backend

2018-08-24 Thread Benjamin SOULAS
Hi Mark, I am interested on the fact you handled Token from LDAP, to you have examples on ho wdo you implement it? Just for the context, I have to implement an API (with DRF or not, for now it is DRF). For testing it (eg: with Postman) it works fine with DRF Token authentication (easy to imple

Re: Encode and shorten UUIDs in URLs

2018-08-24 Thread Chris Foresman
Yes, this is a better idea than mine. On Fri, Aug 24, 2018 at 8:17 AM gordon wrote: > You could also make a custom uuid field that handles this. Use a uuid > subclass that uses base 58 for string conversion. And then convert to > correct database representation in the field methods > > On Fri,

Re: Encode and shorten UUIDs in URLs

2018-08-24 Thread gordon
You could also make a custom uuid field that handles this. Use a uuid subclass that uses base 58 for string conversion. And then convert to correct database representation in the field methods On Fri, Aug 24, 2018, 9:13 AM Chris Foresman wrote: > It almost sounds like you'd need to patch Django

Encode and shorten UUIDs in URLs

2018-08-24 Thread Chris Foresman
It almost sounds like you'd need to patch Django's URL resolver to look for capture groups that might be a primary key, and then base58 decode the value before passing it as a value to the view method being called. Then you would need to write your own function, `my_reverse`, which would look fo

DRF authentication with django-LDAP module compatible?

2018-08-24 Thread Benjamin SOULAS
Hello everyone, I my project, I used the DRF Token authentication (more convenient for token set in header from client call). But I need also to handle LDAP users, so went on the django-auth_ldap readthedocs site, I saw it is compatible with django authentication, but is it with DRF authenticat

Re: Database for Unit Test

2018-08-24 Thread Marc Chakiachvili
depends if you run tests with python command or via manage.py tests command I think. BTW: Usually DEBUG parameter in settings.py make you don't care about ALLOWED_HOST param. Marc Le ven. 24 août 2018 à 09:28, Alexander Lamas a écrit : > Hi Marc, > > No, this is my database settings > > DATAB

Re: Database for Unit Test

2018-08-24 Thread Alexander Lamas
Hi Marc, No, this is my database settings DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mydb', 'USER': 'root', 'PASSWORD': 'masterkey', 'HOST': 'localhost', 'PORT': '3306', 'TEST': {'NAME' : 'test_mydb'},

Re: Development and Production environment

2018-08-24 Thread Marc Chakiachvili
You may use environment variable instead of having multiple configuration settings. You can also use some package dedicated to that such as django-environ in your settings.py Then add a sample file config.env.sample to your repository, add config.env ins .gitignored, and setup your env this way Th

Re: Database for Unit Test

2018-08-24 Thread Marc Chakiachvili
Sorry, don't know about Visual Studio for Django / Python dev. Usually use Jetbrains pycharm.. IF it's same code executed, have a look at the command line (if possible) that actually launch VIsual Studio on test launch. did you paer chance set any parameter such as keepdb ? (Which disable the db c