am I supposed to add my migrations to VC, or should they be generated on the machine whenever I do a release?
Effenberg0x0 has quit
mattmcc
Migrations should be version controlled, otherwise there'd be no history.
hell_razer has quit
BabySuperman has quit
Lobstaman3 has quit
litewait joined the channel
Tordek
mattmcc: alright, thanks!
litewait has quit
bePolite joined the channel
eefvx has quit
eefvx joined the channel
hell_razer joined the channel
jessamynsmith joined the channel
hell_razer has quit
Hydhen joined the channel
jiang42 joined the channel
tomdavidson has quit
tomdavidson joined the channel
pantsofchocolate has quit
Tyris has quit
Tyris joined the channel
jarshwah_ has quit
RicoAlpha joined the channel
eefvx has quit
Kaspi joined the channel
sudomarize has quit
CrowX- has quit
fllr joined the channel
hell_razer joined the channel
coderzm joined the channel
tomdavidson has quit
heatmeiser joined the channel
domino14 joined the channel
isthisreallife joined the channel
hell_razer has quit
MasterPhi has quit
heatmeiser has quit
ojii has quit
onr has quit
RicoAlpha has quit
brockhaywood joined the channel
ryanhiebert joined the channel
ryanhiebert
When should I implement Model.clean() vs Model.save()? I want to make sure that a flag I have (is_advisor) doesn't conflict with a ManyToMany relationship (advisees). Which is the right place to check that?
meninoebom has quit
cnk joined the channel
Skandocious
I **believe** model.clean() only gets called when you use model forms
I might be wrong
ryanhiebert
The docs say that save() does not call clean()
Skandocious
well then there ya go
you're no guaranteed to get a clean() call all the time
ryanhiebert
will the admin understand a ValidationError raised in save()?
Skandocious
save = guarantee unless you're using an SQL terminal
fission6_ joined the channel
no you can't throw validationerrors from save
domino14 has quit
unless you catch them yourself
ryanhiebert
no guarantee on save for update() either
Skandocious
ah, that might be true...
crap really
lol
ryanhiebert
OK, I better put that logic in both places then.
Skandocious
ive actually not found a good way to raise validation errors back to forms in the model save routines
Lobstaman3 joined the channel
one thing ive done is used some middleware to grab the request object inside the model.save() method, then write out a message with message.error(), and **dont** save the object
you'll get an error at the top of the page but not a field-specific error in the form inputs
mattmcc
The way model validation is implemented, it should be run before calling model.save()
There's no mechanism for raising validation errors from save.
ryanhiebert: The admin uses ModelForms, which call model validation.
So you do not need to duplicate your validation.
Andy80 joined the channel
Lobstaman3 has quit
Skandocious
mattmcc: if i understand correctly, you mean to say that a **responsible user** should run full_clean from his business logic and catch/handle validation errors prior to calling save?
that's the intended development paradigm?
mattmcc
Skandocious: Only if you're calling model.save() directly from your code (not using a ModelForm)
Skandocious
right
got it
fission6_ has quit
Lobstaman3 joined the channel
ryanhiebert
I've been using Django for years, and I did not realize I was "supposed" to do that.
Skandocious
can't say that i ever recall calling full_clean manually...
mattmcc
Since if you're not using forms, the right way to communicate validation errors to the user isn't clear.
Skandocious
ryanhiebert: me too
Lobstaman3 has quit
mattmcc: that's true... though it's possible to use **forms** instead of **ModelForms**
in which case it's pretty clear on how errors should be communicated (should look the same as model forms)
litewait joined the channel
but with bare forms you can't call save() so i usually end up pulling out field values and constructing an object piece by piece before calling save
lvanderpool is now known as mekhami
and skipping the full_clean() call (cuz i didnt realize i was expected to call it)
mattmcc
What made you choose to do that over using ModelForm?
Skandocious
but yes i understand the issue-- the model doesn't know where to attach the errors if there's no ModelForm present
mattmcc: sometimes my forms are not a direct representation of a model
mattmcc
That's fine. ModelForms are still forms, you can add other form fields that don't map to the model.
Skandocious
mattmcc: sometimes they're a big mish-mash of many models
mattmcc
Similarly, you can exclude model fields from the form which you don't want to mess with.
Lobstaman3 joined the channel
Yeah, saving to multiple models, you're pretty much on your own. Unless it's a case where it'd make sense to process one post request with multiple form classes, which isn't that unusual.
dcrouch has quit
E.g, two related objects, but where an inline formset doesn't make sense.
Skandocious
mattmcc: yeah ive done that too, using form_prefix
eka has quit
RicoAlpha joined the channel
a_little_birdie
quick question.. is it not allowed for appname/static to contain subdirectories?
mattmcc
That'd be pretty silly.
Much like with templates, subdirectories provide namespacing for static files.
appname/static/appname/css/this-apps-css.css
gamesbrainiac has quit
isthisreallife has quit
Lobstaman3 has quit
Which would be found using {% static "appname/css/this-apps-css.css" %}
lorddaedra has quit
Lobstaman3 joined the channel
a_little_birdie
ok thanks the reason I'm asking is because I do have that, but collectstatic is blowing up with an error
File "/opt/env/ssbc/lib/python2.7/site-packages/django/core/files/storage.py", line 238, in delete
os.remove(name)
OSError: [Errno 21] Is a directory: '/home/django/ssbc/static/app'
app is my subdirectory
Lobstaman3 has quit
RicoAlpha has quit
of course if collectstatic wants to delete that, I've got a different issue and should be glad it couldn't unlink a directory
BabySuperman joined the channel
ls
Lobstaman3 joined the channel
litewait has quit
Hmm ok if anyone understands collectstatic really well, please take a look at this error: https://dpaste.de/xhaQ#L40
RicoAlpha joined the channel
It seems to copy all my files, but then fails at the end because it wants to unlink a directory in my STATIC_ROOT
FunkyBob
a_little_birdie: do you have a dir called app in one static die, and a file of the same name?
a_little_birdie: does the problem happem if you remove everything in STATIC_ROOT ?
a_little_birdie
I don't think I have more than one directory called app.
Let me try
lorddaedra joined the channel
mattmcc
Um, what does manage.py findstatic "app" say?
Since it thinks it should be a file, you might actually have a file (not directory) of that name inside a static dir somewhere.
FunkyBob is sitting at the airport, waiting to fly to PyConAU
zz_theskumar is now known as theskumar
a_little_birdie
Found 'app' here:
/home/django/git/ssbc/ssbc/static/app
FunkyBob
wait
sbogg has quit
oh, ok.. thought you had a static source dir inside your STATIC_ROOT
is that a file or a dir?
a_little_birdie
it's a directory
mattmcc
No it's not, findstatic wouldn't have 'found' it if it was.