Giter Site home page Giter Site logo

Comments (4)

eshaan7 avatar eshaan7 commented on May 24, 2024

Hi, @hodunov. It makes me glad that you found this library useful.

So I can better address this issue, can you let me know the python and django versions your project is using ?

from django-rest-durin.

eshaan7 avatar eshaan7 commented on May 24, 2024

If you see the code inside durin/models.py, we have a custom AuthTokenManager where the create method is overwritten. It seems as though that the get_or_create in your example is calling the default create and not the overwritten create of AuthTokenManager.

On digging more into this, I find that this was fixed in Django v1.8a1 as mentioned in this StackOverflow thread, quoted below,

Just want to clarify that this issue was addressed in Django v1.8a1. So now both get_or_create and update_or_create will call the managers create method as expected.

from django-rest-durin.

hodunov avatar hodunov commented on May 24, 2024

Hi, @hodunov. It makes me glad that you found this library useful.
So I can better address this issue, can you let me know the python and django versions your project is using ?

Yes, of course, no problem. Django==3.2 with python 3.8

Absolutely right, rushed and did not describe my thoughts on this matter. I agree that the reason is exactly in models.Manager.
And yes, I saw that get_or_create method should work with manager, but it doesn't, check it yourself.

from django-rest-durin.

sunweiyang avatar sunweiyang commented on May 24, 2024

I have an interesting situation too -- AuthToken.objects.get_or_create works in most cases, but when I'm performing Django unit tests, AuthToken.objects.get_or_create within the API views I'm testing doesn't work (but they do work in the unit tests themselves, before I call the API views!).

from django-rest-durin.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.