[patch]'django_admin.py/manage.py install app' - confusing models validation

2 views
Skip to first unread message

Kuba Konczyk

unread,
Feb 5, 2006, 4:34:39 PM2/5/06
to django-developers group
Hello.

I have two applications in my project app1 and app2 with defined
models and app2 model have error(s).I want to install app1:

$ django-admin.py install app1
Error: app1 couldn't be installed, because there were errors in your model:
app2.choices: At least one field in Choice should have core=True,
because it's being edited inline by polls.Poll.

Both models are separated,so why when I want to install app1 I get
error about app2?I just want to install app1, I don't care about app2
model now.

'django_admin.py/manage.py install app1 app2 ... appN ' command is
using 'get_validation_errors' function to validate models.For every
application from command line 'get_validation_errors' validate _all_
models from installed modules.
I think this is too much.We only need to validate applications models
that we want to install and maybe also core modules.

The solution is to change 'get_validation_errors' to accept optional
list of modules for which models we want to validate.The previous
behaviour of 'get_validation_errors' is not changed and it's
default.'django_admin.py/manage.py validate' works as previous.

I don't know if validation of models from core modules is necessary
when installing new application(s), but may be good idea in some
cases.For example when using User from auth module in some models.

Patches included:
management.py+get_validation_errors.patch
management.py+get_validation_errors+core_modules_validation_on_install.patch

management.py+get_validation_errors.patch
management.py+get_validation_errors+core_modules_validation_on_install.patch

Russell Keith-Magee

unread,
Feb 11, 2006, 5:17:47 AM2/11/06
to django-d...@googlegroups.com
On 2/6/06, Kuba Konczyk <jaka...@gmail.com> wrote:
> I think this is too much.We only need to validate applications models
> that we want to install and maybe also core modules.

Hi Kuba,

Well spotted. This is a problem - however, the solution isn't quite as
simple as your patch, because you need to check for the existence of
dependencies. For example, if you install app1, and app1 has a
ForeignKey on app2.mymodel, then you shouldn't b allowed to install
app1 without app2.

I've logged this as ticket 1343
(http://code.djangoproject.com/ticket/1343), and put you on the cc
list. I should get a chance to work on this in the next few days.

Russ Magee %-)

jkk

unread,
Feb 12, 2006, 9:41:04 AM2/12/06
to Django developers
Hi Russel.

Thanks for your reply.I admit my patch is rather naive;).I'm currently
working on better solution according to your advices.

Kuba

Russell Keith-Magee

unread,
Feb 16, 2006, 9:11:32 AM2/16/06
to django-d...@googlegroups.com
Hi Kuba,

I just added a patch for this to the magic-removal branch (as ChangeSet 2310).

Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages