Re: Problems with initial data

2007-12-14 Thread Tane Piper
Sorry folks, something weird is going on with my email - I'm able to send emails but I don't receive them from the list, so I never got your replied (and it would have saved me a long time searching) Thanks for your replies On Dec 14, 8:56 am, "Tane Piper" <[EMAIL PROTECTED]> wrote: > Manage

Re: Problems with initial data

2007-12-14 Thread Tane Piper
Managed to fix it. Had a hunt in the django code for what the admin modules does and discovered the Model.objects.get_or_create function. Now works perfectly! On 13/12/2007, Tane Piper <[EMAIL PROTECTED]> wrote: > Ok, I've modified this slightly, however still cannot get this to > work. To tes

Re: Problems with initial data

2007-12-13 Thread jim
I think you need to be using 'fixtures' for this purpose. http://www.djangoproject.com/documentation/models/fixtures/ e.g. I have an application called common, so I created a xml file called 'initial_data.xml' in the directory: apps\common\fixtures the initial_data.xml looks like:

Re: Problems with initial data

2007-12-13 Thread James Bennett
On Dec 13, 2007 2:14 PM, Tane Piper <[EMAIL PROTECTED]> wrote: > So, I modified it so each import is a function, and each has it's own > dispatcher with a sender (being IssueType, IssueSeverity and > IssueStatus) - however when the models are created they don't get > called. Take the sender away

Re: Problems with initial data

2007-12-13 Thread Tane Piper
Ok, I've modified this slightly, however still cannot get this to work. To test it, I put a print statement at the top of the function and called syncdb, and sure enough the function was being called 8 times! So, I modified it so each import is a function, and each has it's own dispatcher with a

Re: Problems with initial data

2007-12-13 Thread James Bennett
On Dec 13, 2007 10:36 AM, Tane Piper <[EMAIL PROTECTED]> wrote: > dispatcher.connect(init_issues_database, signal=signals.post_syncdb) This will set up the code to run every single time an application is installed. Not just the application it resides in, but *every* application. You want to look

Re: Problems with initial data

2007-12-13 Thread Rajesh Dhawan
Hi, > > from django.dispatch import dispatcher > from django.db.models import signals > > from hgfront.issue.models import * > > def init_issues_database(): > """This injects the database with default values for issues""" > issue_types = ( > ('Bug', 0), > ('Enhancment', 1)

Problems with initial data

2007-12-13 Thread Tane Piper
Hi folks, In our app, we're building a simple Issue list app, and within the app we want to add some basic entries for issue type, issue status and issue severity. Within our /issue directory, I have created a management.py file and added this: from django.dispatch import dispatcher from django