These are chat archives for django/django

13th
Feb 2017
Alex Lee
@createall
Feb 13 2017 00:56
Hello, I'm newbie on django and ORM programming. And I'm familiar with developing database with procedure. If I want to develop django with procedure(mysql or mssql) where can I found best articles and references?
Roel
@roelzkie15
Feb 13 2017 07:30
it is recommended to change the 'static' of STATIC_URL to any desired name?
Antonis Christofides
@aptiko
Feb 13 2017 08:15
@createall What do you mean "develop database with procedure?"
@badcoder28 STATIC_URL customarily has the value /static/, but you can change it to anything you like. If you use a CDN (or otherwise serve your static files from another server), it would be //yourstaticserver.com/, for example.
Alex Lee
@createall
Feb 13 2017 10:08
@aptiko I want to make database related logic in database procedure. And I will call procedure in django code.
Antonis Christofides
@aptiko
Feb 13 2017 10:16
@createall Django does not support this directly, so whatever you do will be database-specific. I've tried this but through the years I concluded it's more trouble than it's worth, and I removed all such database logic from my apps. You can generally put logic nicely in Django. If you don't have a compelling reason (such as software beside Django accessing the same database), I think you shouldn't do it.
@createall And since you are new to this, I propose to do it the Django way in order to get some better understanding before deciding to move forward to what you are considering.
@createall The way you call a database procedure is executing custom SQL, as explained in https://docs.djangoproject.com/en/1.10/topics/db/sql/#executing-custom-sql-directly.
Roel
@roelzkie15
Feb 13 2017 15:08
@aptiko thanks for that
Philip Eckert
@pae4557
Feb 13 2017 16:18
So when using .save(commit = False) I get a validation error because the form data isn't complete yet. How can I add something into the form instance (from the view) to ensure it validates?
I tried making an instance for the view, adding it, then saving the instance, but I can't create the instance in the first place because the field I want to add is missing at the point of form.save(commit = False)
Seems to be circular logic here: form doesn't validate, so I need to add data to it, but I can't create the instance to do so because the form doesn't validate. How am I supposed to get around this?
Philip Eckert
@pae4557
Feb 13 2017 16:40
FYI, figured this one out: the ModelForm must NOT include the data field that needs to be added for model validation