Re: Manually added foreign key not working.

2013-02-24 Thread laxmikant ratnaparkhi
Does anybody can answer this?

Let me know if anything extra is required?

Thanks in advance...


Laxmikant

On Wed, Feb 20, 2013 at 6:23 PM, laxmikant ratnaparkhi
<laxgl...@gmail.com>wrote:

> Hello all,
>
> I just run a command to Add foreign key to the existing table. and the
> command was like this:
>
> *ALTER TABLE acfs_subscriptionmaster ADD CONSTRAINT FK_Formats FOREIGN
> KEY (id) REFERENCES acfs_formats (id) MATCH FULL;*
>
> It has got executed. but giving error on the interface
>
> column acfs_subscriptionmaster.FK_Formats_id does not exist
> LINE 1: ...ccountmaster"."id") INNER JOIN "acfs_formats" ON ("acfs_subs...
>
> *What could be the reason, What Should I do to solve this. I can't DROP
> Table. ?*
>
> *my models.py looks like this :*
>
> class SubscriptionMaster(models.Model):
> """
> """
> uid = models.TextField(blank=True, null=True)
> FK_SubsType = models.ForeignKey(SubscriptionType)
> FK_Product = models.ForeignKey(ProductMaster)
> *FK_Formats = models.ForeignKey(Formats)
> <<--Added this field in
> models.py
> *ccs_minimum_price = models.TextField(blank=True, null=True)
> ccs_maximum_price = models.TextField(blank=True, null=True)
> ccs_Increment_type = models.TextField(blank=True, null=True)
> ccs_minimum_increment = models.TextField(blank=True, null=True)
> ccs_maximum_increment = models.TextField(blank=True, null=True)
> ccs_default_offer = models.TextField(blank=True, null=True)
>
> Checked SQL Got created by *python manage.py sqlall* acfs
>
> This is my table :
>
> CREATE TABLE "acfs_subscriptionmaster" (
> "id" serial NOT NULL PRIMARY KEY,
> "uid" text,
> "FK_SubsType_id" integer NOT NULL REFERENCES "acfs_subscriptiontype"
> ("id") DEFERRABLE INITIALLY DEFERRED,
> "FK_Product_id" integer NOT NULL REFERENCES "acfs_productmaster"
> ("id") DEFERRABLE INITIALLY DEFERRED,
> *"FK_Formats_id" integer NOT NULL REFERENCES "acfs_formats" ("id")
> DEFERRABLE INITIALLY DEFERRED, <--This field has got created
> here *
> "ccs_minimum_price" text,
> "ccs_maximum_price" text,
> "ccs_Increment_type" text,
> "ccs_minimum_increment" text,
> "ccs_maximum_increment" text,
> "ccs_default_offer" text,
> );
>
> Also its howing indexes like this :
>
> CREATE INDEX "acfs_subscriptionformats_FK_Format_id" ON
> "acfs_subscriptionformats" ("FK_Format_id");
> CREATE INDEX "acfs_subscriptionmaster_FK_SubsType_id" ON
> "acfs_subscriptionmaster" ("FK_SubsType_id");
> CREATE INDEX "acfs_subscriptionmaster_FK_Product_id" ON
> "acfs_subscriptionmaster" ("FK_Product_id");
> CREATE INDEX "acfs_subscriptionmaster_FK_Formats_id" ON
> "acfs_subscriptionmaster" ("FK_Formats_id");
>
> Looks like error is field has not got created in actual database :
> *python manage.py dbshell*
> *acfsdb1=# SELECT * FROM acfs_subscriptionmaster;*
>  id | uid | FK_SubsType_id | FK_Product_id | ccs_minimum_price |
> ccs_maximum_price | ccs_Increment_type | ccs_minimum_increment |
> ccs_maximum_increment | ccs_default_of
> fer | fix_startdatetime | fix_expiydatetime | fix_price | dur_period |
> wd_field_01 | wd_field_02 | wd_field_03 | wd_field_04 | wd_field_05 |
> flag_field_01 | created_dat
> e_time | modified_date_time
>
> +-++---+---+---++---+---+---
>
> +---+---+---++-+-+-+-+-+---+
> ---+
> (0 rows)
>
> This is my DJANGO - Python versions
>
> Django Version: 1.2.7  Exception Type: DatabaseError  Exception Value:
>
> column acfs_subscriptionmaster.FK_Format_id does not exist
> LINE 1: ...ccountmaster"."id") INNER JOIN "acfs_formats" ON ("acfs_subs...
>  ^
>
>  Exception Location: 
> /usr/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py
> in execute, line 44  Python Executable: /usr/bin/python  Python Version:
> 2.6.6*postgres 9.1*
>
>
> Traceback Variables (see at the bottom for the error)
> 

Re: How to create a Django Group in case of multiple databases.

2013-02-08 Thread laxmikant ratnaparkhi
I have not trimmed traceback. This is ouput came on python manage.py shell.

And one more thing I modified save method This looks like this:

   def save(self):
if not self.id:
self.created_date_time = datetimeToUTC()
self.modified_date_time = datetimeToUTC()
self.modified_date_time = datetimeToUTC()
super(ModelName, self).save()
if not self.uid:
self.uid = idmaptoalpha.getUID(self.id)
super(ModelName, self).save()

 Can you plz tell me if anything is wrong in it.

Thanks again.

*N.B.:*But I have not  modified method for Django's Group  Table. This is
only for the new Classed I created.

Regards,
Laxmikant


On Thu, Feb 7, 2013 at 11:49 PM, Tom Evans  wrote:

> On Thu, Feb 7, 2013 at 12:16 PM, laxglx  wrote:
> >
> > Hello Everybody,
> >
> > I'm going to create a Group using Django Group.
> >
> > I have two databases one is "master" and another is "slave"
> > In master I created a user and group as usual.
> >
> > And in slave database I tried like this:
> >
> >
>  Group.objects.db_manager('slave').create(name="grp1")
> >
> > This returned an error :
> >
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/usr/lib/python2.6/site-packages/django/db/models/manager.py",
> line
> > 138, in create
> > return self.get_query_set().create(**kwargs)
> >   File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line
> > 358, in create
> > obj.save(force_insert=True, using=self.db)
> > TypeError: save() got an unexpected keyword argument 'force_insert'
>
> Have you trimmed this traceback?
>
> >
> > I also tried as follows, but got error :
> >
>  g = Group()
>  g.name = "grp1"
>  g.save(using='slave')
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: save() got an unexpected keyword argument 'using'
> >
>
> It looks like you have overwritten the save() method on the model you
> are trying to save, and have not given it a method signature capable
> of accepting the necessary arguments that save() is expected to
> handle.
>
> I say 'looks like', since I think you have obliterated the parts of
> the traceback that would tell me…
>
> save() takes many arguments. If you are not specifying any additional
> arguments for your save() method, then it should look like so:
>
> def save(self, *args, **kwargs):
>
> This protects you from having to change the method if more arguments
> are added in later versions of django, eg when the 'using' argument
> was added in 1.2.
>
> As usual, the docs have canonical instructions on how to override
> model methods like save():
>
>
> https://docs.djangoproject.com/en/1.4/topics/db/models/#overriding-model-methods
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Kindly help for an interview with Google on python django

2013-01-31 Thread laxmikant ratnaparkhi
Hello Everybody,
  I have an interview scheduled on monday with google. So can you
anybody have an related information  or any experience. Please help me what
would be asked for this interview.
 I have 2 years of exp in python and django.

Thanks in advance!!!

regards,

Laxmikant

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.