"The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources." https://pypi.org/project/psycopg2-binary/
FunkyBob
newdimension: that's what I use
newdimension
psycopg2-binary?
FunkyBob
yes
newdimension
ok, thank you
FunkyBob
was not aware of advice to not use it in production
muvlon joined the channel
Ruzzy has quit
muvlon
Hello django people!
FunkyBob
hi
muvlon
I'm kinda new and have a bit of an architectural question
I have a problem that I believe I could solve using either a Formset or several individual Forms
is there a preferred way to do this? i.e. when both could be applied, does one of them have a clear advantage?
FunkyBob
that depends on what the problem is
muvlon
of course, I'll specify
I want to build a view for creating an instance of Model A + a few instances of model B that have a foreign key pointing at the newly created A
elit3x has quit
but the number and some of the fields of the Bs are already known at the time the form is initialized and should not change
So there'd be 2 forms, a regular ModelForm and an inline formset?
FunkyBob
yes
muvlon
oh, there's a max_num parameter
that way I can stop the formsets from creating more than the pre-determined number of things even if somebody fumbles with the request
FunkyBob
yes
muvlon
neat
I'll give it a try
I had seen inline formsets before but had assumed they were only supposed to be used for variadic formsets
arthurio joined the channel
FunkyBob
understandable
arthurio has quit
djapo joined the channel
muvlon_ joined the channel
csotelo joined the channel
muvlon_
uhm wait
there seems to be no "initial" keyword argument on inlineformset_factory
do I have to populate it manually somehow?
FunkyBob
doesn't the factory function return a formset class ... and you pass initial to that?
muvlon_
ooooh right
i see it now
of course, i could instantiate that several times
should, even
making a new factory on every request is probably not the smartest thing
opticdel1sion joined the channel
jhoskins98 joined the channel
opticdelusion has quit
opticdel1sion is now known as opticdelusion
newdimension has quit
another question, if it is okay
is it a bad idea to put a lot of logic into the view? or into a form class?
FunkyBob
no
pahn joined the channel
elit3x has quit
jgadelange has quit
muvlon_
okay, so inlineformsets don't allow for an initial parameter
i think they're more suited for the case when all the objects already exist in the DB and are related
i don't want to save my objects before i've received and validated the form (don't mutate in GET requests and so on)
so I'll try a modelformset instead
jgadelange joined the channel
jhoskins98 has left the channel
pahn has quit
pahn joined the channel
elit3x joined the channel
bkxd joined the channel
bkxd has quit
arthurio joined the channel
FunkyBob
muvlon_: I suspect it's expecting a queryset of objects to edit
but I'm not sure... I don't use formsets
Dunedan joined the channel
muvlon_
I've only recently started
I used to just shove a lot of forms into a single <form> element
and make sure the prefixes were unique
Dunedan_ has quit
FunkyBob
quite valid
arthurio has quit
hkc joined the channel
elit3x has quit
TestCity joined the channel
TestCity
Hello. I have a project with 2 kinds of users. Mayor and Residents. What would be the base way to create the two types of models? Profiling or Extending the BaseUser? Users should be able to post complains and ask questions to the mayor. Mayor does not have address, gender fields etc but residents have those. Thanks.
FunkyBob
why would they be two types of model?
isn't it just a flag on the user record to indicate a mayor?
TestCity
ok
that might work
muvlon_
alternatively, you can have three models: User, Mayor, Resident
both Resident and Mayor have a OneToOne to User
TestCity
ok
muvlon_
address, gender etc are then fields on Resident, not on User
FunkyBob
so the difference between a Mayor and a Resident is that you've stored the extra fields?
TestCity
but since there will only be 1 mayor, I think I should only use OneToOne Field with a User(which may be both mayor and resident)
is that right?
FunkyBob
ah, well, enforcing that only one person is Mayor ... can be fun :)
tdy joined the channel
also... is every Resident necessarily a user who can log in?
TestCity
yes
u0083 has quit
u0083 joined the channel
miz- joined the channel
rpkilby joined the channel
rpkilby has quit
chasonchaffin has quit
giaco has quit
elit3x joined the channel
matsaman joined the channel
u0083 has quit
u0083 joined the channel
Draconis joined the channel
Draconis
Hi all. Having issues getting django to log to stdout. Reading docs it seems like I just define a LOGGING dict in settings.py? Does this look wrong? https://dpaste.de/5q1T
matsaman
talking about runserver, or...?
Draconis
yeah runserver
u0083 has quit
u0083 joined the channel
lorddaedra has quit
lorddaedra joined the channel
chasonchaffin joined the channel
FunkyBob
looks ok, Draconis
is there something that makes you think it's not working?
robinb joined the channel
debsan has quit
agrawalritesh joined the channel
schinckel
Do you need to store when the mayor is mayor? Or is the data just a snapshot in time?
robinb
I would like to have an app called products which has the models category and offer. I'm wondering about how I can have those two urls in the same urls file though? I would like to have the url mysite.com/categories/1 or mysite.com/offers/1 I guess.