https://github.com/dfunckt/django-rules looks simple to implement. Django Guardian seems like it could work, too, but seems more complex. Which do you recommend or do you have another recommendation?
theology has quit
I'm using the latest Django, btw.
slamtime has quit
mcspud
I've used guardian very successfully
stavros joined the channel
stavros
hello
milardovich has quit
jmill has quit
bradfordli123 joined the channel
i created a custom user model for a new project that doesn't have a username field, only an email field, and set the REQUIRED_FIELDS etc properly, but "createsuperuser" complains that it didn't receive a username
what's the proper fix for that? i got that error on multiple projects
stavros: ran into that issue earlier this month. i just created a new user manager and copied the existing createsuperuser method
slamtime joined the channel
stavros
OtherAllan, yeah, that seems to be the only solution, but i would have expected it to work, seems like a Django bug
cilkay
mcspud, Is there a way to create the roles using /admin with guardian?
stavros
OtherAllan, can you paste me your code to save me digging through the manager docs?
knbk
stavros: you changed USERNAME_FIELD, but you didn't actually remove the username field that's defined on AbstractUser. You can set `username = None` (and run makemigrations/migrate)
mcspud
cilkay - I'd create the groups programmatically, and assign permissions to them programmatically also
gacrux has quit
cilkay - it basically creates a "default state"
stavros - you need to override the baseusermanager
knbk
(stavros: assuming you don't want the username field at all)
stavros
knbk, if i do that, it crashes because the UserAdmin refers to "username" in its ordering field
OtherAllan
stavros: knbk's solution might work and is probably better. i cant completely remove my username field for now
cilkay
mcspud, I'll already have the players, coaches, teams, and league in models so it would be nice to be able to grant appropriate permissions to them on an object or group level.
mcspud
cilkay - you can do it through admin, but that is a cumbersome manual process
Its a nice, predictable way to control authorisation during resource creation
Your only manual step is putting people in the groups
stavros
OtherAllan, you override it as objects = NewUserManager() on the User, right?
OtherAllan
yep
cilkay
mcspud, Thanks. That looks simple enough. I was planning on assigning users to groups on import anyway. This is not a self-registration site.
shallow has quit
shallow joined the channel
theology joined the channel
stavros
OtherAllan, still fails with an odd error: "TypeError: 'username' is an invalid keyword argument for this function" when your _create_user is trying to call self.model()
sorry, i mean the UserManager's _create_user
OtherAllan
are you doing something like self._create_user(username=username) ?
stavros
do we need to override create_user too?
no, UserManager._create_user is doing that
user = self.model(username=username, email=email, **extra_fields)
i wonder if i should just override both and just call super() with username=email
OtherAllan
did you remove username from your model? (i.e. username = None) ? that probably would cause it
i still have it on mine
stavros
OtherAllan, ah yes, i did
that'd do it, thanks... let me experiment a bit
this feels like a bug, you shouldn't have to jump through all these hoops to remove the username field when this is an explicitly sanctioned use case in the docs
chunhao has quit
kingarmadillo has quit
OtherAllan
yeah kind of i guess. i didnt catch it until a lot later since i dont use ./manage.py createsuperuser much
all other usages in django work fine
stavros
i only use it once, but i'd like to do it "properly", and it doesn't feel like it's proper unless things work
but yeah, for my last project i just ignored it and things work fine
i just decided now to figure out how to fix it, but apparently there's no easy fix
kloudi- joined the channel
kanja has quit
BigJono joined the channel
Lcstyle has quit
OtherAllan, the only thing that works is taking the whole UserManager class, overriding things and removing username, in case you're interested
kloudi has quit
knbk
the docs explicitly say that if you don't use a field `username` or some of the other fields on AbstractUser, you need to define your own create_(super)user methods -- https://docs.djangoproject.com/en/2.0/topics/au...
kingarmadillo joined the channel
OtherAllan
ah. well there you have it
BigJono has quit
lolidunno joined the channel
synchroack has quit
stavros
ah, i see, thanks
fikka joined the channel
milardovich joined the channel
enkrypt has quit
stavros has quit
detseg joined the channel
milardovich has quit
kingarmadillo has quit
chasonchaffin joined the channel
enkrypt joined the channel
CAPITANOOO joined the channel
fikka has quit
CAPITANOOO has quit
theology
anyone hiring?
xliiv joined the channel
Hazy joined the channel
milardovich joined the channel
Hazy
Can I use/consume java APIs with django?
Lcstyle joined the channel
justanr joined the channel
exaroth has quit
mcspud
Yes
DigitalDarwin joined the channel
As long as you aren't serializing classes
In java parlance, you aren't "marshalling objects"
coderphive joined the channel
Lcstyle has quit
Hazy
thanks. Can you point me at some reading material on the subject?
coderphive has quit
coderphive joined the channel
brainpro1 joined the channel
brainproxy has quit
kamba joined the channel
bradfordli123 has quit
Lcstyle joined the channel
mcspud
go and read about XML or REST
They are standard, web-friendly data formats
For django-specific stuff check out django-rest-framework or django-nap