one is by react ( facebook ) community and other is by django
Kangermu
cool_dude: thats an entirely different question :P
realnot
guys, if I want to use a custom manager everywhere? for example filtering by user objects.filter(user=request.user) and only if the user is superuser use the classic objects.all()
kanja has quit
I mean, when I use objects.all() this should filter by user. Instead if I user superobjects.all() this is not filtered
It's a bad idea?
sackrebutz has quit
kezabelle
well, without using a threadlocal for request, you have to pass the request along somehow
chocoelho joined the channel
cool_dude
yes Kangermu you are right
realnot
yeah, the dubt now is not about retrieving the `request`, I used request.user as example. I just want to swtich this logic
obects.all() is a queryset always filtered by `domain` for example
superobjects.all() is not filtered by domain
kezabelle
... you still need to pass the value in somehow.
realnot
what about creating a mixin that define a manager?
Hello! I've deployed a django app using Gunicorn and Nginx, but I can't access the django admin page, even though I create a superuser (and have run migrations), it just says username and password is wrong. even though I've created multiple superusers to test. Any idea where the problem might be? I can post any config you guys want, but not sure what you want
kanja joined the channel
fleetfox
are you sure web application and cli is accessing same database?
porfiriopaiz has quit
knbk
vimes: is the user active?
fleetfox
createsuperuser creates active user
assuming you have not messed with it or usermodel
vimes
knbk: I would assume so, I did the same process on localhost and it worked ifne
no I have not
I did use certbot's nginx package to generate ssl for https though
ssv
try manage.py shell and get all user form auth model
vimes: are user.username and user.password as expected (i.e. user.password is a password hash)?
(and I'd check user.is_active just to be sure, even if the default is True)
fleetfox
ar you using sqlite?
iamriel
Hi guys, I am developing an api for a mobile app using django rest, my problem is the mobile team wants us to support passing of "id" to a resource, that means they are the ones who will create the ID/primary key of the model, is it okay to support that one? we are using uuid for the id btw
giarc joined the channel
chasonchaffin has quit
vimes
not quite sure how to check that, let me google knbk , fleetfox I'm using postgres
knbk
vimes: what exactly are you not sure about?
ssv
vimes: ok, is there user which you created? if yes, probably you need to check your settings.py
vimes
knbk: how to see if passwords are hashed, but I have not fiddled with how django should store passwords
ssv: yes the users I created are there
ssv
vimes: try to use a sqlite3 as a default database and also set your SECRET_KEY as a 'abcd' and try to create user again
knbk
vimes: well, if user.password is a plaintext password it is not hashed, otherwise it probably is
ssv: huh, why exactly?
ssv
vimes: what version of django you use?
knbk
vimes: also check user.has_usable_password()
vimes
knbk: you misunderstand the true level of my incompetence, I'm unsure how to get user.password (andreas.password). I tried importing * from django.contrib.auth.model and calling andreas.password with no luck
1.11 knbk
seemed like the sensible version to use
knbk
vimes: right. You know how to get a queryset, right? you can get a specific user by using `user = User.objects.get(username='andreas')`
ssv
knbk: I'm not sure, maybe he's create a user with one secret key then change it and try to log in :)
knbk
then you can print user.password, etc.
colegatron has quit
ssv: the secret key has no effect on whether you can log in
ssv
knbk: I mean, when you create a new password
knbk
it's used for password reset tokens and to sign cookies, but that doesn't matter in this case
vimes
knbk: yes the password is a hash
I do have a differnet settings file for the server and localhost, but I don't see how it should mess things up
knbk
vimes: does `user.check_password('your_password')` return True?
redir joined the channel
vimes
knbk: yes it returns true
detseg joined the channel
ssv
knbk: you're right, my bad (only for sessions, messages and password reset token).
so your shell was using a different database. You need to create the user while using the production settings file
ssv
knbk: hm, maybe need to check AUTH_USER_MODEL and set if it not default.
sounds like very strange.
khomesh has quit
vimes
knbk: so it seems. can I set it to use the prod. database, or do I always have to manually go into shell with the correct settings defined?
I figured it out! I just create superuesr with the --settings. Thank you !!!!
ssv
oh, yay!
gz
fleetfox
is there an easy way to swtich default databases at runtime?
jadajada joined the channel
iamriel
knbk: I see, thanks :D
jpg has quit
ironbeard
Is there any performance difference between setting a model's __str__ to something like '{}: {}'.format(self.region, self.year) vs having a 'name' field on the model that is set to the same string once and then saved? With the name field, then I would set __str__ to self.name. Particularly if an instance's 'name' is dependent on many fields and ForeignKeys of the instance.