Siecje, I know I can do that. But users may not have all the information at the beginning, but still need to add the property.
And they should be able to see a list of incomplete properties, and add information to them later.
In this case, the borrower info.
I thought there would be some method with modelform that would return true if the form is empty.
I'm surprised there is not.
Siecje
So isn't it doing what you want?
It creates a model that you can modify later?
chowmeined joined the channel
AleksTK
Siecje, right. It creates models for all of them. But I want it to check the form for each model (except property), see if it is blank. And if it's blank, not add that model, and simply not set the foreign key for the corresponding property model.
Does that make sense?
So with the example picture I sent you.
It should make every model except the borrower model, link them to property, and add them to the database.
Because the borrower field is blank.
I just don't know an easy way of checking of all the fields in the borrower modelform are blank.
Except I guess checking each one and hardcoding the field names in the view.
mribeirodantas joined the channel
heatmeiser joined the channel
Siecje
You should pass an instance into each form
So if you already have a borrower pass that borrower instance into the form
AleksTK
Siecje, I do that on an update page.
But you
*you're looking at the add new property page.
Siecje
(8:08:05 PM) AleksTK: It should make every model except the borrower model, link them to property, and add them to the database.
What is it doing?
AleksTK
It's making every model, and adding it to the database.
Including a borrower model, with all blank fields, which is linked to the property model.
Instead, it should detect the borrower form as blank, and not add it.
I haven't written the code to do that.
Because I'm not sure how.
trey joined the channel
Sorry if I seem thick, I'm sure this is really simple.
I'm new to Django though.
Siecje
AleksTK: Try form.has_changed()
Nux17 joined the channel
Nux17
Hey, someone with celery + gevent experience here ?
il joined the channel
AleksTK
Siecje, good idea.
pokEarl joined the channel
il is now known as Audioburn
bigDicts joined the channel
That works.
bigDicts
how can i run django without a db
Nux17
set DATABASES to an empty dict
AleksTK
Siecje, thanks.
bigDicts
i get an error settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
AleksTK
I saw that before but thought it wouldn't work for some reason.
hey all. i'm having trouble understanding the correct way to use select_related, even after reading the docs. can someone review this simple example (along with the error message i get) and perhaps steer me in the right direction? https://dpaste.de/B4HP
dirigeant has quit
Derailed has quit
django347
@ AleksTK, just noticing what you are talking and might be a bit out of context. You might be talking about the isValid() function? That checks if fields are blank/invalid.
AleksTK
django347, I thought that only applied to required fields.
All these fields are optional.
django347
Also, I'm still definitely wondering about the error, it really is quite confusing to me
AleksTK
By the way I really appreciate this IRC channel. It helps me a lot.
django347, my error?
I already fixed everything, by using the function Siecje suggested.
django347
Ah, yes, you are right. I didn't realize you wanted it for non required fields
Oh no, my error from earlier.
pilva joined the channel
bigDicts
im having some issues getting my static files to load on live server
django347
That is good, that you have everything fixed
AleksTK
bigDicts, I /just/ had that issue.
I couldn't figure out why static files in one app loaded but not in another.
shawnadelic has quit
After around 30 minutes of debugging everything, I realized I put a slash in front of the static directory.
trey has quit
{% static '/properties/css/test.css' %}
Instead of {% static 'properties/css/test.css' %}
bigDicts
i have Debug set to false, STATIC_URL and STATICFILES_DIRS defined
AleksTK: im using <link rel="stylesheet" href="static/css/main.css"/>
AleksTK
bigDicts, any reason you aren't using {% static %}?
Goopyo has quit
And do you have {% load static %} at the top of your file?
bigDicts
no, im using jinja template engine not DTL so that throws an error
randyinthedesert, thanks for the suggestion. i tried 'product = Product.objects.select_related('productversion_set').get(id=id)' but unfortunately i got the error "Invalid field name(s) given in select_related: 'productversion_set'. Choices are: (none)"
i'm not familiar with the "_set" thing so i'll look into it and perhaps it will steer me in the right direction
Honestly, I'm rather new at this, so I'm not sure.
randyinthedesert
select_related only accepts field names or reverse relationship sets as args
bigDicts
same here lol
django347
Out of curiosity, what does + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) return?
bigDicts
i have no clue..i followed the docs
I assume its appending a static url based on the settings
Goopyo joined the channel
joshlegs has quit
zirikili has quit
django347
Probably. But, if it goes in order, then your r"" is going to override it
So maybe you could try adding the r"" after you add the static url?
(To clarify, the regex r"" matches all unmatched strings up to that point)
migbot joined the channel
noteness has quit
randyinthedesert has quit
zirikili joined the channel
mribeirodantas has quit
noteness joined the channel
grindmodeon has quit
ciderkk
sigh. This reverse foreign key relationship thingy works fine in the shell but not in the view
pokEarl has quit
dray3 joined the channel
django347
Also, another clarification, bigDicts, you can just change the [] + static to static + []
Oh wait, I found it
This helper function works only in debug mode and only if the given prefix is local (e.g. /static/) and not a URL (e.g. http://static.example.com/). Also this helper function only serves the actual STATIC_ROOT folder; it doesn’t perform static files discovery like django.contrib.staticfiles.
So that's why it wasn't working in production, but it was working in debug
bigDicts
aha!
WeiJunLi has quit
zirikili has quit
geez..so i guess i need to move the static folder to the root dir