diff options
author | Nishanth Amuluru | 2011-01-07 11:00:22 +0530 |
---|---|---|
committer | Nishanth Amuluru | 2011-01-07 11:00:22 +0530 |
commit | 9e99caf7e08b47460d9ee7f1b24ae46e0b0b21c9 (patch) | |
tree | fa2393580141e48d5cb661849ca1c80bb1e348ba | |
parent | c2a414e18d19c304bc5a1d9f74639968cc86bef5 (diff) | |
download | pytask-9e99caf7e08b47460d9ee7f1b24ae46e0b0b21c9.tar.gz pytask-9e99caf7e08b47460d9ee7f1b24ae46e0b0b21c9.tar.bz2 pytask-9e99caf7e08b47460d9ee7f1b24ae46e0b0b21c9.zip |
Added seed_db
-rw-r--r-- | profile/__init__.pyc | bin | 0 -> 146 bytes | |||
-rw-r--r-- | profile/forms.pyc | bin | 0 -> 3317 bytes | |||
-rw-r--r-- | profile/management/__init__.py | 1 | ||||
-rw-r--r-- | profile/management/commands/__init__.py | 0 | ||||
-rw-r--r-- | profile/management/commands/seed_db.py | 46 | ||||
-rw-r--r-- | profile/models.pyc | bin | 0 -> 3783 bytes |
6 files changed, 47 insertions, 0 deletions
diff --git a/profile/__init__.pyc b/profile/__init__.pyc Binary files differnew file mode 100644 index 0000000..888cd78 --- /dev/null +++ b/profile/__init__.pyc diff --git a/profile/forms.pyc b/profile/forms.pyc Binary files differnew file mode 100644 index 0000000..657cbf5 --- /dev/null +++ b/profile/forms.pyc diff --git a/profile/management/__init__.py b/profile/management/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/profile/management/__init__.py @@ -0,0 +1 @@ + diff --git a/profile/management/commands/__init__.py b/profile/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/profile/management/commands/__init__.py diff --git a/profile/management/commands/seed_db.py b/profile/management/commands/seed_db.py new file mode 100644 index 0000000..b8ceabe --- /dev/null +++ b/profile/management/commands/seed_db.py @@ -0,0 +1,46 @@ +import sys +from datetime import datetime +from django.core.management.base import NoArgsCommand + +from django.contrib.auth.models import User + +from pytask.profile.models import Profile + +def seed_db(): + """ a method to seed the database with random data """ + + + for i in range(1,21): + + username = 'user'+str(i) + email = username+'@example.com' + password = '123456' + dob = datetime.now() + gender = "M" + aboutme = "I am User"+str(i) + address = "I live in street"+str(i) + phonenum = "1234567890" + + new_user = User.objects.create_user(username=username, + email=email, + password=password) + + new_profile = Profile() + new_profile.user = new_user + new_profile.dob = dob + new_profile.aboutme = aboutme + new_profile.gender = gender + new_profile.address = address + new_profile.phonenum = phonenum + if i%2 == 0: + new_profile.rights = "CT" + elif i%3 == 0: + new_profile.rights = "CR" + new_profile.save() + +class Command(NoArgsCommand): + + def handle_noargs(self, **options): + """ Just copied the code from seed_db.py """ + + seed_db() diff --git a/profile/models.pyc b/profile/models.pyc Binary files differnew file mode 100644 index 0000000..30b07ad --- /dev/null +++ b/profile/models.pyc |