if a model has a foreignkey relationship to another model... for instance, I have a Match model that has exactly two Player models
Kid_For_Today has quit
Hairy joined the channel
Should i do Player1 = ForeignKey(Player) and player2 = ForeignKey(Player)? if so, how do i manage the related_name conflicts?
Hairy has quit
FunkyBob
mekhami: you manage it by doing what the error says -- explicitly setting a related_name on the ForeignKey
mekhami
if not, should I do a many2many relationship and somehow limit the number of acceptable related instances?
FunkyBob, in this case, what would I set related_name to? I've always just set it to what the related model calls this model, which in this case would be Match for both players
FunkyBob
set it to whatever makes sense to you
mekhami
but obviously you can't have the same related_name, or, if you can, it's still throwing me the same error
I'm not sure what does make sense to me
FunkyBob
when you want to get to the matches where a player was Player1....
describe the relation, not the model
is there some implied difference between being player1 or 2 for a Match?
mekhami
no
doesn't matter either way
FunkyBob
does it, for instance, decide who serves first?
mekhami
no
that gets decided randomly
and won't have any impact on this app
Guddu has quit
nacsurte joined the channel
nacsurte
do most django devs use the admin panel with their apps or do they not
Goopyo joined the channel
FunkyBob
nacsurte: I use it to get started... and inspect what's going one
on, not one
gratimax
nacsurte: yes, it's a very useful way to get started with your app
atula joined the channel
mekhami
FunkyBob, were you heading somewhere with that last question? Cause I'm still a bit foggy
FunkyBob
mekhami: I'd go with two fkeys... and just pick names like "player1_matches" and "player2_matches"
mekhami
will this be difficult to work with later when i want to get all matches a player was in?
having to query both player2_matches and player1_matches to get total matches etc
atlasloewenherz joined the channel
FunkyBob
not greatly, no
the real trick is forcing the two keys to never hold the same value
metastableb joined the channel
eN_Joy joined the channel
carljm
mekhami: When I've had a case like that, I've often found that in actuality there was some difference in the roles of the two players, and I could use more meaningful names for the two FKs
Goopyo_ joined the channel
Goopyo has quit
Goopyo_ is now known as Goopyo
e.g. I have a system I'm working on that manages appointments between two participants, and rather than "participant1" and "participant2" I have "requestor" and "recipient", because one of the two parties requested the appointment.
(maybe in your case there is no such distinction at all, but something to consider)
mekhami
yeah there really is no distinction, so i'm wondering if i even need two foreignkeys.
carljm
well, if there are always exactly two players, I still think two FKs is the best option.
FunkyBob
+1
atlasloewenherz has quit
opnchaudhary joined the channel
opnchaudhary has left the channel
eN_Joy has quit
eN_Joy joined the channel
nacsurte
gratimax, FunkyBob: what about for production level apps
carljm
nacsurte: Sure, I've often used the admin. Not always. Depends if it meets a need in the project.
gratimax
you can still use the admin, but be sure to secure it
carljm
It's been a long time since I've had a project where the admin really saw heavy use as the primary admin UI; usually it's not quite flexible enough for that. But even on those projects I often keep it around as a handy way for non-technical staff to peek "directly" into the db when necessary.
mindcruzer has quit
eN_Joy has quit
mekhami
when i run tests using django.TestCase, it's not affecting my main database, right?
FunkyBob
right
mekhami
so why did i get the 'not null, no default, needs to populate existing rows' message from makemigrations when i haven't actually put anything in the main database?
codeitloadit joined the channel
FunkyBob
mekhami: because it doesn't matter what's in it
it matters what _could_ be in it
mekhami
ah
i always feel guilty setting null=True
FunkyBob
what sort of field is it?
mekhami
ForeignKey
merkelraute has quit
it won't have a default, nor will it ever be null..
FunkyBob
yeah... to add them you're usually best (1) add it nullable, (2) set values, (3) remove nullable
kanja joined the channel
amites has quit
robvdl has quit
mekhami has quit
eN_Joy joined the channel
kunalg joined the channel
dheerajchand joined the channel
SuperLag has quit
brockhaywood has quit
eN_Joy has quit
abara has quit
donspaulding has quit
bite joined the channel
autrilla__ has quit
dheerajchand
Hey, all, looks like the folks at #chicagodjango started a pretty great tutorial but never finished it! Anyone able to help me figure out a roadmap from here ? I am trying to create a dev environment in a Vagrant VM and write an Ansible playbook for a Python 2.7, Django 1.7, GeoDjango project. https://www.chicagodjango.com/blog/new-django-s...
atula has quit
donspaulding joined the channel
brockhaywood joined the channel
eN_Joy joined the channel
k_sze[work] joined the channel
SmileyChris has quit
eN_Joy has quit
eN_Joy joined the channel
brockhaywood has quit
eN_Joy has quit
Siecje has quit
eN_Joy joined the channel
jessamynsmith has quit
amites joined the channel
heatmeiser joined the channel
eN_Joy has quit
Hasimir has quit
eN_Joy joined the channel
subho joined the channel
kelseygi has quit
kelseygi joined the channel
heatmeiser has quit
paratox joined the channel
paratox has quit
paratox joined the channel
Threedee joined the channel
TheAdversary joined the channel
flebel has quit
eN_Joy has quit
Nizumzen has quit
kelseygi has quit
kanja has quit
kelseygi joined the channel
flebel joined the channel
brockhaywood joined the channel
atlasloewenherz joined the channel
limbera
"TypeError: create_user() takes at least 5 arguments (5 given)"