Comments (7)
I looked over the past Issues, it seems this was solved, and somehow it was broken again. I tried re adding the 2 lines that were removed from the models.py file:
User._meta.pk = User._fields["id"]
User._meta.pk.value_to_string = lambda obj: smart_text(obj.pk)
However it then failed on setting this attribute, I guess the _meta.pk property is not editable there.
To solve it for now I added these same 2 lines to our own User models.py file, so that now it has the _meta.pk attribute. This seems to work. However I think there should be a solution that will make this work straight from mongoengine
from django-mongoengine.
Hello. I've removed that hack becouse i was added value_to_string
method to PkWrapper
.
Just checked login on example project, and it works.
from django-mongoengine.
Hi,first thanks for the help.
It doesn't work on our project, our settings are as shown in the example.
AUTH_USER_MODEL = 'mongo_auth.MongoUser'
MONGOENGINE_USER_DOCUMENT = 'models.users.User'
We use a custom User model that we created using mongoengine. Not the default model from the auth.
The problem is that the user model that authenticate returns is our own User model, and not mongo_auth.MongoUser.
even if we do MongoUser.objects.get(email="user_email") we get our User model. And so it doesn't containt the PkWrapper and doesn't have the _meta.pk attribute.
Like I said, If we add the _meta.pk attribute to our own model it solves it.
It should be possible to work with a custom User Mongoengine model, and still authenticate in my opinion. It also used to work this way before the split.
Do you have any ideas how to solve this?
from django-mongoengine.
Probably your custom User model uses mongoengine.Document instead of django_mongoengine.Document, so wrappers does not applied
from django-mongoengine.
Yes you are right, our custom user model inherits straight from mongoengine.Document.
So the solution should be to inherit from django_mongoengine.Document ?
I see that that inherits from mongoengine.Document it self. So it should be transparent and work, if we inherit from django_mongoengine.Document ?
from django-mongoengine.
Yes, django_mongoengine.Document just add that missing properties required by django stuff
from django-mongoengine.
Great, thanks a lot for the help, and for maintaining this library, will try with this change and test it out.
Maybe add to the docs somewhere, that if you use a custom model, you should inherit from django_mongoengine.Document (since before the split, there was no difference between the 2).
This also works with our own custom authentication backends by the way. So it should basically work with any authentication backend.
from django-mongoengine.
Related Issues (20)
- How does the Permission are automatically made in auth module? HOT 1
- get_deleted_objects needs to be changed for admin view HOT 1
- Appconfig models is empty OrderedDict HOT 4
- Too slow with >1K documents! HOT 2
- unable to createsuperuser HOT 1
- Sub query using mongoengine
- fixes for django:3.1 import FieldDoesNotExist
- FieldDoesNotExist import Exception HOT 1
- there are many RemovedInDjango40Warning warnings HOT 2
- something wrong with django_mongoengine/forms/document_options.py HOT 4
- mongo-admin from django_mongoengine not supporting FieldList. Throwing ValidationError for list HOT 3
- Cannot import EMPTY_CHANGELIST_VALUE in django VERSION = (3, 0, 8, 'final', 0) HOT 2
- Is this package still maintained? HOT 1
- Admin pagination seems to be off by one. HOT 2
- Do not recommend djongo in the readme. HOT 1
- Is this project alive? HOT 4
- UI issue HOT 2
- Using list in a "not_contains" query HOT 1
- ModuleNotFoundError: No module named 'typing_extensions' HOT 3
- '_thread._local' object has no attribute 'no_dereferencing_class' for simple querryset HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-mongoengine.