In Django Admin.StackedInline is not working in OneToOneField?

2020-08-14 Thread puneetm...@gmail.com
Below is my Base class class User(AbstractUser): class Meta: verbose_name =_("Student") verbose_name_plural = _("Students") ROLE = ( ('STUDENT', 'Student'), ('TEACHER', 'Teacher'), ('STUDENT-TEACHER', 'Student-Teacher') ) username = models.CharField(verbose_name=_('Username'), max_length=100,

Re: multiplate table inheritance subclass with extra OneToOneField relationship to parent class

2020-07-20 Thread Brian Maissy
I'm still using the workaround I mentioned above -- 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 view this

Re: multiplate table inheritance subclass with extra OneToOneField relationship to parent class

2020-07-19 Thread shubham vashisht
n.wife. > > > It seems like Django is automatically promoting my OneToOneField to be > the one which holds the reference to the parent class. But that's not what > I intended. I want there to be an extra wife relationship in addition to > the implicit automatic OneToOneField. &

Re: Django Migration gives an error with OneToOneField

2020-02-23 Thread maninder singh Kumar
wo different >> dbRouters. On migrating a model with a OneToOneField I get the following >> error : >> >> django.db.utils.OperationalError: (1824, "Failed to open the referenced >> table 'auth_user'") >> >> >> The auth dbRouter is for the [auth, sess

Re: Django Migration gives an error with OneToOneField

2020-02-23 Thread Integr@te System
outers. On migrating a model with a OneToOneField I get the following > error : > > django.db.utils.OperationalError: (1824, "Failed to open the referenced > table 'auth_user'") > > > The auth dbRouter is for the [auth, sessions, contenttypes, admin] apps > while the Redford

Django Migration gives an error with OneToOneField

2020-02-23 Thread maninder singh Kumar
I am working on an application with two databases and two different dbRouters. On migrating a model with a OneToOneField I get the following error : django.db.utils.OperationalError: (1824, "Failed to open the referenced table 'auth_user'") The auth dbRouter is for the [auth

multiplate table inheritance subclass with extra OneToOneField relationship to parent class

2019-10-17 Thread Brian Maissy
the migration, I get the following error: django.core.exceptions.ImproperlyConfigured: Add parent_link=True to > webapp.MarriedMan.wife. It seems like Django is automatically promoting my OneToOneField to be the one which holds the reference to the parent class. But that's not what I intended. I w

Multiple table inheritance subclass with an additional OneToOneField relationship to the parent class

2019-10-17 Thread Brian Maissy
the migration, I get the following error: django.core.exceptions.ImproperlyConfigured: Add parent_link=True to > webapp.MarriedMan.wife. It looks like Django is promoting the wife OneToOneField to be the parent_link relationship. But that's not what I'm trying to do. I want MarriedMan to h

Re: setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
eating a ticket, not sure if this > is intended behavior but it looks like a bug to me. > > I have a pre_save method that populates a non-nullable OneToOneField in > case it is not set at save time. > > class A(Model): > > b = models.OneToOneField(B, on_delete=

setting ForeignKey/OneToOneField in pre_save is not effective - bug?

2019-09-22 Thread Martín Massera
Hi guys I'm posting this here before creating a ticket, not sure if this is intended behavior but it looks like a bug to me. I have a pre_save method that populates a non-nullable OneToOneField in case it is not set at save time. class A(Model): b = models.OneToOneField(B, on_delete

Re: OneToOneField value must be a model instance, not a value?

2019-01-02 Thread Kuber Sodari
ce a different field, that field must have unique=True." May be read it once, you will get some clearance. I didn't quite understand your use-case though. Can you explain it, which field are you using OneToOneField for and why? On Wednesday, 2 January 2019 21:57:09 UTC+5:45, regtech wrote: >

OneToOneField value must be a model instance, not a value?

2019-01-02 Thread regtech
Hello everyone! I am a junior who is first using OneToOneField, I found that the value which is giving to the field only could be a instance of the related model, can't be a value of the field which is specifed by the "to_field" ( else django will raise excption ). In the other word,

Re: Error at OneToOneField in models while creating new models class

2018-09-26 Thread Srinivas Gadi
It was fixed by adding the "section.apps.Class.Config" in settings INSTALLED_APPS On Thu, Sep 27, 2018 at 5:05 AM luca bocchi wrote: > seems that your app is not in settings.INSTALLED_APPS, add 'section' there > and retry. > > L > > Il giorno lunedì 24 settembre 2018 13:22:48 UTC+2, Srinivas

Re: Error at OneToOneField in models while creating new models class

2018-09-26 Thread luca bocchi
seems that your app is not in settings.INSTALLED_APPS, add 'section' there and retry. L Il giorno lunedì 24 settembre 2018 13:22:48 UTC+2, Srinivas Gadi ha scritto: > > Thank you for the response, > 1. Deleted the migrations folder > 2. Removed the SQLite3 DB itself > 3. My dir structure. > >

Re: Error at OneToOneField in models while creating new models class

2018-09-24 Thread Srinivas Gadi
Thank you for the response, 1. Deleted the migrations folder 2. Removed the SQLite3 DB itself 3. My dir structure. 24-09-2018 16:37 . 24-09-2018 16:37 .. 23-09-2018 15:06 college 19-09-2018 08:56 554 manage.py 19-09-2018 10:59

Re: Error at OneToOneField in models while creating new models class

2018-09-23 Thread Adolfo Cueto
First you have to change your model name Class names starts with uppercase... My friend.. you are not making migrations... look at you have to do this: 1. Delete your migration folder 2. Delete you app table manually (DROP table) 3. python manage.py makemigrations app_name 4. migrate that's

Re: Error at OneToOneField in models while creating new models class

2018-09-23 Thread Srinivas Gadi
Yes, provided the migrations out put in the second mail On Sat, 22 Sep 2018, 17:11 Matthew Pava, wrote: > Did you try running your migrations? > > Get Outlook for Android > > > > > On Sat, Sep 22, 2018 at 5:07 AM -0500, "Srinivas Gadi" < > srini@gmail.com> wrote: > >

Re: Error at OneToOneField in models while creating new models class

2018-09-22 Thread Matthew Pava
Did you try running your migrations? Get Outlook for Android On Sat, Sep 22, 2018 at 5:07 AM -0500, "Srinivas Gadi" mailto:srini@gmail.com>> wrote: Adding more and complete details: I am facing below error while creating a new model class. the error pops up only

Re: Error at OneToOneField in models while creating new models class

2018-09-22 Thread Srinivas Gadi
Adding more and complete details: I am facing below error while creating a new model class. the error pops up only at this line "user = models.OneToOneField(User)" *"E1120:No value for argument 'on_delete' in constructor call"* section/models.py from django.db import modelsfrom

Error at OneToOneField in models while creating new models class

2018-09-22 Thread Srinivas Gadi
HI All, I am facing below error while creating a new model class. the error pop up only at this line "user = models.OneToOneField(User)" *"E1120:No value for argument 'on_delete' in constructor call"* from django.db import models from django.contrib.auth.models import User class

Re: 'OneToOneField' object has no attribute 'get' in function-based view

2017-03-15 Thread Vijay Khemlani
tions') is not None: > Exception Type: AttributeError at /work/add/Exception Value: 'ObjectName' > object has no attribute 'get' > > > > I ended up trying a different approach, splitting these forms into two > separate views. I was able to pass the pk of the first (title)

Re: 'OneToOneField' object has no attribute 'get' in function-based view

2017-03-15 Thread Pedro Paulo Palazzo
r at /work/add/Exception Value: 'ObjectName' object has no attribute 'get' I ended up trying a different approach, splitting these forms into two separate views. I was able to pass the pk of the first (title) form to the second (register) through the URL and to prepopulate the latter's OneToOneField wi

Re: 'OneToOneField' object has no attribute 'get' in function-based view

2017-03-15 Thread Vijay Khemlani
t; > > I am writing a two-part form where I want to pass the object saved in the > first part as a OneToOneField for the object in the second part. > > In views.py: > > > def object_entry(request): > if request.method == 'POST': > title_form = TitleEntry(

'OneToOneField' object has no attribute 'get' in function-based view

2017-03-15 Thread Pedro Paulo Palazzo
I am writing a two-part form where I want to pass the object saved in the first part as a OneToOneField for the object in the second part. In views.py: def object_entry(request): if request.method == 'POST': title_form = TitleEntry(request.POST) object_form = ObjectEntry

Re: Two profile types with OneToOneField relationship with User

2016-11-26 Thread eltongoci
as described shortly here: > https://dpaste.de/Bgao, I > > have created an abstract user profile which is tied to Django's User > model > > with OneToOneField relationship. So I have AbstractProfile, and then > there > > are IndividualProfile and Bu

Re: Two profile types with OneToOneField relationship with User

2016-11-26 Thread ludovic coues
Have you tried `getattr(u, 'individualprofile', None)` ? 2016-11-26 15:17 GMT+01:00 <eltong...@gmail.com>: > Hi guys > > I'm on Django 1.10, and as described shortly here: https://dpaste.de/Bgao, I > have created an abstract user profile which is tied to Django's User model &g

Two profile types with OneToOneField relationship with User

2016-11-26 Thread eltongoci
Hi guys I'm on Django 1.10, and as described shortly here: https://dpaste.de/Bgao, I have created an abstract user profile which is tied to Django's User model with OneToOneField relationship. So I have AbstractProfile, and then there are IndividualProfile and BusinessProfile, each of which

Re: How to delete a OneToOneField reverse relation?

2015-12-19 Thread James Schneider
I believe that delete() only deletes the reference to the object in the database, but does not affect the calling object in memory. I think the reason for this is so that you can perform a delete operation, and if successful, gather information about the deleted object to display a confirmation

How to delete a OneToOneField reverse relation?

2015-12-19 Thread Evan Heidtmann
My question is very similar to one by Seth Gordon in 2011. But it's been 4 years since then, so I'll try again. I have models A and B, and B has a O2O field pointing to A. When I do `a.b.delete()`, then I'm surprised to find that `a.b` is still a valid object. How can I modify `a` so that it

Re: Migrating from OneToOneField to ForeignKey in Django models

2015-12-03 Thread Simon Charette
Hi Cajetan, You can visit the ticket [1] and have a look and the commit messages. In this case the fix have been backported to 1.7.4[2] and should be part of Django 1.8+. Simon [1] https://code.djangoproject.com/ticket/24163 [2]

Re: Migrating from OneToOneField to ForeignKey in Django models

2015-12-03 Thread Cajetan Rodrigues
Hi, I faced this issue recently and stumbled onto this thread. I see that the ticket has been fixed and closed already. How do I see which Django release has the fix shipped with? Thanks for your help. Cajetan. On Saturday, 17 January 2015 04:07:21 UTC+5:30, Łukasz Harasimowicz wrote: > > It's

Re: Usage of select_related() on a OneToOneField with parent_link=True doesn't work

2015-11-14 Thread Simon Charette
t; Using Django 1.8.3, I have 2 models, both unmanaged (remote DB managed by > another system), with something similar to that: > > class Parent(Model): > ... some fields... > > class Child(Model): > id = OneToOneField(primary_key=True, parent_link=True) > ... some other

Usage of select_related() on a OneToOneField with parent_link=True doesn't work

2015-11-14 Thread Gilad
Hi, Using Django 1.8.3, I have 2 models, both unmanaged (remote DB managed by another system), with something similar to that: class Parent(Model): ... some fields... class Child(Model): id = OneToOneField(primary_key=True, parent_link=True) ... some other fields ... Notes: 1. Parent

Re: Migrating from OneToOneField to ForeignKey in Django models

2015-01-16 Thread Łukasz Harasimowicz
It's me again. I have managed to reproduce the problem and I have created a ticket: https://code.djangoproject.com/ticket/24163. W dniu poniedziałek, 12 stycznia 2015 23:32:54 UTC+1 użytkownik Łukasz Harasimowicz napisał: > > Hi Colin. > > On behalf of my colleague I will answer your question:

Re: Migrating from OneToOneField to ForeignKey in Django models

2015-01-12 Thread Łukasz Harasimowicz
Hi Colin. On behalf of my colleague I will answer your question: We did not have time (at this moment) to investigate this problem any further. We've added a raw sql commands to disable foreign key checks during this migration. We could do it since we are still learning Django (and it's new

Re: Migrating from OneToOneField to ForeignKey in Django models

2015-01-12 Thread Collin Anderson
Hi, Did you figure it out? This seems like a bug. Can you reproduce it with a fresh project? Thanks, Collin On Friday, January 9, 2015 at 8:49:56 AM UTC-5, Maciej Szopiński wrote: > > Hi everyone, > > I've encountered an issue when working with django and I can't seem to > find a way out of

Migrating from OneToOneField to ForeignKey in Django models

2015-01-09 Thread Maciej Szopiński
Hi everyone, I've encountered an issue when working with django and I can't seem to find a way out of this.. I am using django 1.7.2 and a MySQL database. I have a model that was using a One-to-One relationship with two other models. At first I thought, the One-to-One relationship will be

Re: delete OnetoOneField link

2014-12-30 Thread madjardi
thank you. you give me more confidence вторник, 30 декабря 2014 г., 17:19:53 UTC+3 пользователь Vijay Khemlani написал: > > If you want to change a user's cashbox then yes, you would need to use > your solution, but it's easier to get c1 by just saying > > c1 = user.cashbox > > instead of

Re: delete OnetoOneField link

2014-12-30 Thread Vijay Khemlani
If you want to change a user's cashbox then yes, you would need to use your solution, but it's easier to get c1 by just saying c1 = user.cashbox instead of Cashbox.objects.get A more definite solution would be to add the OneToOne relation to the User model instead of the Cashbox object, but

delete OnetoOneField link

2014-12-30 Thread madjardi
class Cashbox(models.Model): cashier = models.OneToOneField('User', null=True, blank=True, related_name='cashbox', on_delete=models.SET_NULL) in other code: User.object.get(pk=1) user.cashbox = None AttributeError: 'NoneType' object has no attribute 'cashier_id' one version solving is: c1

OneToOneField revese lookup question

2014-06-06 Thread Mehmet Gultas
Using the model below, I am trying to extend User. And with the related view I am trying to reach the method of AnkediDolduran model. authonticate() gives me a User instance, right? How can I reach the method of the model AnketiDolduran using this instance of User? Thanks in advance. class

Re: Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Benjamin Wohlwend
Hi Tom, On Wednesday, June 12, 2013 10:25:24 AM UTC+2, Tomáš Ehrlich wrote: > > Hi Benjamin, > you can create explicit OneToOne field with parent_link=True > > https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.OneToOneField.parent_link > > > Then you can set different

Re: Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Tomas Ehrlich
t; > class Link(Content): > url = models.URLField() > > > class Teaser(Content): > text = models.TextField() > link = models.URLField() > > > As we all know, Django uses an implicit OneToOneField for model > inheritance. This OneToOneField generates accesso

Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Benjamin Wohlwend
() link = models.URLField() As we all know, Django uses an implicit OneToOneField for model inheritance. This OneToOneField generates accessors for the reverse relation, which in this case means that objects of the type Content will have a "link" and a "teaser" attribute to a

Re: Is there any way to apply a constraint on ForeignKey/OneToOneField being attached to any model based on some condition ?

2013-02-08 Thread vijay shanker
fortunately my case was really simple, i had to count number of m2m objects attached to my model and storing it as field, and had to make the decision of having a ForeignKey/OneToOne relation based on number of m2m objects attached.I was already using m2m_changed signal ( on post_add ), so i

Re: Is there any way to apply a constraint on ForeignKey/OneToOneField being attached to any model based on some condition ?

2013-02-07 Thread Huu Da Tran
You could overwrite the save() method... or if you are populating from a form, overwrite the clean() method. On Thursday, February 7, 2013 3:23:54 AM UTC-5, vijay shanker wrote: > > Hi > I have these two models Cart and CartItem, > > class Cart(models.Model): > cart_id =

Is there any way to apply a constraint on ForeignKey/OneToOneField being attached to any model based on some condition ?

2013-02-07 Thread vijay shanker
Hi I have these two models Cart and CartItem, class Cart(models.Model): cart_id = models.CharField(max_length= 50, null=False) customer= models.ForeignKey(Customer,null=True,blank=True) cartitems = models.ManyToManyField(CartItem,null=True)

Re: Extend user model: class inheritance or OneToOneField?

2012-07-17 Thread Alessandro De Noia
Hi 2012/7/14 Melvyn Sopacua > > Important question: Why? > > I need to store more information about the user, like birthday, language preference etc Moreover I need to have two different users and store different information for each user type. In a near future I will

Re: Extend user model: class inheritance or OneToOneField?

2012-07-14 Thread Melvyn Sopacua
On 14-7-2012 0:18, sdonk wrote: > I'm starting a new project and for the first time I need to extend the User > model. Important question: Why? > I read the documentation and I googled a lot to try to figure out what is > the best approach but I got confused. > > What's the the best

Re: Extend user model: class inheritance or OneToOneField?

2012-07-13 Thread Ernesto Guevara
er): > birthday = models.DateField(null=True, blank=True) > address = models.CharField(max_length=255, null=True, blank=True) > > objects = UserManager() > > Or OneToOneField (as doc suggests) > > > from django.contrib.gis.db import models > from django.co

Extend user model: class inheritance or OneToOneField?

2012-07-13 Thread sdonk
django.contrib.auth.models import User, UserManager class myUser(User): birthday = models.DateField(null=True, blank=True) address = models.CharField(max_length=255, null=True, blank=True) objects = UserManager() Or OneToOneField (as doc suggests) from django.contrib.gis.db

Re: Error on cascade deletion OneToOneField link with django-pyodbc backend

2012-02-18 Thread akaariai
you might have a possibility to define a filtered unique contraint. Otherwise, remove the constraint in the database schema (the django model could still have the OneToOneField for validation purposes) or alter your business logic in a way that the referenced Unit models are also deleted. - Anssi On

Error on cascade deletion OneToOneField link with django-pyodbc backend

2012-02-18 Thread Eugeny Klementev
I have two models with OneToOne relation class Unit (models.Model): label = models.CharField(max_length=32) datastream = models.OneToOneField ('Datastream', null=True, blank=True, related_name="unit") ... class Datastream (models.Model): idd = models.AutoField(primary_key=True,

OneToOneField causes NotFound exception?

2011-10-24 Thread Paolo
Hi, It looks like if I'm using a OneToOne field (with blank=True etc set) and happen to try and access this field when it's Null (or None) then I get a NotFound exception? My expectation was it would return None of nothing was set, not raise an exception? I could of course catch this

Re: removing the source of a OneToOneField relationship

2011-05-05 Thread PFL
query your target object after you delete a source object. The delete() On May 3, 2:05 pm, Seth Gordon <se...@ropine.com> wrote: > I have one Django model that points to another one with a OneToOneField, > sort of like this: > > class Target(models.model): >     # stuf

Re: removing the source of a OneToOneField relationship

2011-05-04 Thread Seth Gordon
On 05/04/2011 12:43 AM, Andy McKay wrote: > > On 2011-05-03, at 2:05 PM, Seth Gordon wrote: >> I get an exception, complaining that Target.source does not allow >> null values. > > You'll probably want to allow null values on your OneToOne field then: > >

Re: removing the source of a OneToOneField relationship

2011-05-03 Thread Andy McKay
On 2011-05-03, at 2:05 PM, Seth Gordon wrote: > I get an exception, complaining that Target.source does not allow > null values. You'll probably want to allow null values on your OneToOne field then: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.null -- Andy

Re: removing the source of a OneToOneField relationship

2011-05-03 Thread Andy McKay
On 2011-05-03, at 2:05 PM, Seth Gordon wrote: > I get an exception, complaining that Target.source does not allow > null values. You'll probably want to allow null values on your OneToOne field then: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.null -- Andy

removing the source of a OneToOneField relationship

2011-05-03 Thread Seth Gordon
I have one Django model that points to another one with a OneToOneField, sort of like this: class Target(models.model): # stuff class Source(models.Model): target = models.OneToOneField(Target) Sometimes, given an object that is an instance of Target, I want to navigate to its Source

Error when editing Inline OneToOneField

2011-02-07 Thread Pascal Germroth
Hi, using SVN revision 15440 I get some weird behaviour: Part of my model looks like this: - from django.contrib.gis.db import models class Address(models.Model): uuid = UuidField(primary_key=True) readable = models.CharField(max_length=200) geo = models.GeometryField() def

OneToOneField in "Dynamic Model" referencing another dynamic model.

2010-07-18 Thread Massimiliano della Rovere
Each class Blocks/cliente/num1/num2 has a OneToOneField related to the corresponding class Telefonate/cliente/num1/num2: how to write class Blocks? in particular the OneToOneField? class Blocchi(models.Model): call = models.OneToOneField(Telefonate, unique=True, primary_key=True) block_sta

Re: OneToOneField usage

2010-06-16 Thread bob84123
> Is there a particular reason why using a related OneToOneField raises > DoesNotExist instead of returning None? > > | class Person( Model ): > |    pass > | > | class Pet( Model ): > |    owner = OneToOneField( Person ) > | > | # Assuming "joe" ex

Re: OneToOneField usage

2010-05-14 Thread Peter Herndon
rryMan wrote: >>> >>>> Hello Django users, >>> >>>> Is there a particular reason why using a related OneToOneField raises >>>> DoesNotExist instead of returning None? >>> >>> Any query you make that is supposed to return one or more

Re: OneToOneField usage

2010-05-14 Thread Tom Evans
gt; > Is there a particular reason why using a related OneToOneField raises >> > DoesNotExist instead of returning None? >> >> Any query you make that is supposed to return one or more instances, that >> instead cannot find any results, returns a DoesNotExist. > > Not tr

Re: OneToOneField usage

2010-05-13 Thread TallFurryMan
Thanks for this insight. I was using OneToOneField in the same way as ForeignKey. | class Person( Model ): | pass | | class Pet( Model ): | owner = ForeignKey( Person ) | | # Assuming "joe" exists as a Person | >>> kitty = joe.pet_set.get_or_create() Yes, in that sit

Re: OneToOneField usage

2010-05-13 Thread Daniel Roseman
On May 13, 5:35 pm, Peter Herndon <tphern...@gmail.com> wrote: > On May 13, 2010, at 10:29 AM, TallFurryMan wrote: > > > Hello Django users, > > > Is there a particular reason why using a related OneToOneField raises > > DoesNotExist instead of retur

Re: OneToOneField usage

2010-05-13 Thread Peter Herndon
On May 13, 2010, at 10:29 AM, TallFurryMan wrote: > Hello Django users, > > Is there a particular reason why using a related OneToOneField raises > DoesNotExist instead of returning None? Any query you make that is supposed to return one or more instances, that instead cannot find

OneToOneField usage

2010-05-13 Thread TallFurryMan
Hello Django users, Is there a particular reason why using a related OneToOneField raises DoesNotExist instead of returning None? | class Person( Model ): |pass | | class Pet( Model ): |owner = OneToOneField( Person ) | | # Assuming "joe" exists as a Person | >>&

OneToOneField produces two inlines?

2010-04-13 Thread wally
I have two models related by a OneToOneField as in the code below, but when I create an inline to display on the admin form for the 'parent' object, I get forms for two of the related objects instead of one (ie an instance of A and two instanced of B). Can anyone suggest why this would be the case

how to use an internal (multi-table inherited) OneToOneField

2010-01-11 Thread }--o
Hi, I have the following three models class AbstractModel title = CharField class Quote(AbstractModel) class Project(AbstractModel) Instead of creating a new Project when a Quote gets accepted, I would prefer extending the Quote's abstractproject_prt instance could someone show me how to

"OneToOneField doesn't allow assignment of None"

2009-12-20 Thread Kieran Brownlees
Hello All, In http://code.djangoproject.com/browser/django/trunk/django/forms/models.py line 53 it states: 53 # OneToOneField doesn't allow assignment of None. Guard against that 54 # instead of allowing it and throwing an error. 55 if isinstance(f

Re: Migrating ForeignField to OneToOneField

2009-12-19 Thread Jonathan
gt; I'm using South to migrate a certain field from ForeignField to > OneToOneField. > Initial state is that I have model A pointing to model B using a > ForeignField. Of course there's only one instance of A pointing to a B > instance. > > I wasn't sure if this would work direc

Re: Generating a single form with OneToOneField

2009-10-04 Thread Russell Keith-Magee
On Sat, Oct 3, 2009 at 2:55 AM, Tiago Samahá wrote: > > Hello All, > > i'm trying generate a single form with two models. > > class Contact(models.Model): >    phone = models.CharField(max_length=8) >    email = models.CharField(max_length=50) > > class

Re: Generating a single form with OneToOneField

2009-10-04 Thread Tiago Samahá
Someone can help me? Thanks. On 2 out, 15:55, Tiago Samahá wrote: > Hello All, > > i'm trying generate a single form with two models. > > class Contact(models.Model): >     phone = models.CharField(max_length=8) >     email = models.CharField(max_length=50) > > class

Generating a single form with OneToOneField

2009-10-02 Thread Tiago Samahá
Hello All, i'm trying generate a single form with two models. class Contact(models.Model): phone = models.CharField(max_length=8) email = models.CharField(max_length=50) class Client(models.Model): name = models.CharField(max_length=50) type = models.CharField(max_length=10)

Good OneToOneField design?

2009-08-14 Thread John M
Hey everyone, I'm trying to use the 1-1 fields, and love the examples and how it works, once it's created. However, I'm having trouble determining when in my code to create the actual instance of the 1-1 object. What I really want is for the save() method of the 'master' side of the model to

Re: multi-table inheritance and modification of OneToOneField options

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 00:30 -0700, Jan Ostrochovsky wrote: > Thank you, Malcolm. > > In fact, our current design was, as you recommended: > > Subject ---one-to-one-null-false--- Address ---one-to-one-null-true--- > Payment (Invoice) > > I want to use generic views and to join Subject+Address

Re: multi-table inheritance and modification of OneToOneField options

2009-08-07 Thread Jan Ostrochovsky
the child model > > and each of its parents (via an automatically-created OneToOneField). > > >http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield > > says: Multi-table inheritance is implemented by adding an implicit one- > > to-one relation from the ch

Re: multi-table inheritance and modification of OneToOneField options

2009-08-06 Thread Malcolm Tredinnick
omatically-created OneToOneField). > > http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield > says: Multi-table inheritance is implemented by adding an implicit one- > to-one relation from the child model to the parent model... > > The question is: how can I set options of

multi-table inheritance and modification of OneToOneField options

2009-08-06 Thread Jan Ostrochovsky
Hello, http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance says: The inheritance relationship introduces links between the child model and each of its parents (via an automatically-created OneToOneField). http://docs.djangoproject.com/en/dev/ref/models/fields

OneToOneField - IntegrityError: PRIMARY KEY must be unique

2009-07-16 Thread Viktor
Hi, I have the following two models: class AcceptedRoleAbstract(models.Model): ''' Represents a User that should accept a role E.g.: Discussant, Reviewer ''' user = models.ForeignKey(User) accepted = models.NullBooleanField(help_text=_("The reviewer agreed to make the

Re: django admin delete oneToOneField ?

2009-06-24 Thread Mr. T
I saw this in the docs: "When Django deletes an object, it emulates the behavior of the SQL constraint ON DELETE CASCADE -- in other words, any objects which had foreign keys pointing at the object to be deleted will be deleted along with it." So it sounds like you don't need to do anything.

django admin delete oneToOneField ?

2009-06-17 Thread Dan Sheffner
ok so I have a list of servers that have a one to one relationship with a table called cpu. When I delete a server from the server table it should also delete it one to one relationship with the cpu entry. right? do I need to pass something extra in the models.py to have this happen?

Re: OneToOneField, and inlines

2009-05-10 Thread nbv4
On May 10, 4:03 pm, Tom von Schwerdtner wrote: > Greetings folks, I've been wrestling with this and I really don't know > what I'm not doing right, so here is where I am: > > In basic pseudocode, I have: > > models.py: > --- > class Address(models.Model): >    

OneToOneField, and inlines

2009-05-10 Thread Tom von Schwerdtner
Greetings folks, I've been wrestling with this and I really don't know what I'm not doing right, so here is where I am: In basic pseudocode, I have: models.py: --- class Address(models.Model): ... ( street, city, etc) class Contact(models.Model): ... address =

Re: syncdb Issue: OneToOneField with User model from contrib.admin

2009-02-07 Thread elith...@gmail.com
Worked perfectly - thanks very much. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email

Re: syncdb Issue: OneToOneField with User model from contrib.admin

2009-02-07 Thread Ramiro Morales
On Sat, Feb 7, 2009 at 7:26 AM, elith...@gmail.com wrote: > > Hi all - I'm having an issue when trying to generate my models after a > syncdb command. I know where it's failing, and almost why - but I'm > also trying to figure out the correct solution to what I'm trying to >

syncdb Issue: OneToOneField with User model from contrib.admin

2009-02-07 Thread elith...@gmail.com
Hi all - I'm having an issue when trying to generate my models after a syncdb command. I know where it's failing, and almost why - but I'm also trying to figure out the correct solution to what I'm trying to achieve. In my model (http://github.com/elithrar/eatsleeprepeat.net/blob/

Re: new record - onetoonefield - create related record

2009-02-06 Thread Karen Tracey
ix what you have so far. First, if you want to leave the OneToOneField defined in hostsetting, then you will need to restructure your unixhost save() to look more like this: def save(self, force_insert=False, force_update=False): # check if 1-1 record is needed need_host

Re: select_related and OneToOneField

2009-02-02 Thread Malcolm Tredinnick
On Mon, 2009-02-02 at 14:40 -0500, Michael Hrivnak wrote: > Does select_related work for OneToOneField relationships? Yes. This wasn't something you could have just tried out and seen for yourself? > If so, does it work > in both directions? No. Probably will in 1.1, but not yet.

select_related and OneToOneField

2009-02-02 Thread Michael Hrivnak
Does select_related work for OneToOneField relationships? If so, does it work in both directions? Thanks, Michael --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

Re: new record - onetoonefield - create related record

2009-01-31 Thread John M
Hi Karen, and thanks for the reply. I've always wanted to use the 1-1 field, but whenever a new parent record is added, I want it to automatically add (via the save() ) ovoerride above to the child 1-1 table. Yes, the debug does print, and the above code seems to work from the shell too, it's

Re: new record - onetoonefield - create related record

2009-01-30 Thread Karen Tracey
On Fri, Jan 30, 2009 at 4:29 PM, John M wrote: > > Given the model's below, I'm trying to make it add the related 1-1 > record automatically, but it's not working, what am i missing? > Perhaps if you described what "not working" looks like in more detail it would be

new record - onetoonefield - create related record

2009-01-30 Thread John M
Given the model's below, I'm trying to make it add the related 1-1 record automatically, but it's not working, what am i missing? Thanks John class unixhost(models.Model): name = models.CharField(max_length=50) # short name fqdn =

Re: OneToOneField relation and bidirectional StackedInline behavior in contrib.admin context

2009-01-28 Thread peschler
2009-01-09 at 05:33 -0800, klein.steph...@gmail.com wrote: > > [...] > > > This error is understandable because actually ClassA haven't > > ForeignKey but the relation > > between ClassA and ClassB is OneToOneField then ClassA know how to > > access to his classb o

Re: OneToOneField relation and bidirectional StackedInline behavior in contrib.admin context

2009-01-09 Thread Malcolm Tredinnick
On Fri, 2009-01-09 at 05:33 -0800, klein.steph...@gmail.com wrote: [...] > This error is understandable because actually ClassA haven't > ForeignKey but the relation > between ClassA and ClassB is OneToOneField then ClassA know how to > access to his classb object. > > Th

OneToOneField relation and bidirectional StackedInline behavior in contrib.admin context

2009-01-09 Thread klein.steph...@gmail.com
/lib/python2.5/site- packages/Django-1.0.2_final-py2.5.egg/django/forms/models.py in _get_foreign_key, line 525 This error is understandable because actually ClassA haven't ForeignKey but the relation between ClassA and ClassB is OneToOneField then ClassA know how to access to his classb object. This

Re: OneToOneField blank=True null=True having an accident

2008-11-30 Thread stevedegrace
y, SubKeyRing, SubKey (rather than as XML like > maybe I should have done) because I wanted to use the Admin interface > with it and not manually edit XML or write a special admin. > > A SubKey has a ForeignKey which is a SubKeyRing to which it must > belong, and a OneToOneField with

OneToOneField blank=True null=True having an accident

2008-11-30 Thread stevedegrace
) because I wanted to use the Admin interface with it and not manually edit XML or write a special admin. A SubKey has a ForeignKey which is a SubKeyRing to which it must belong, and a OneToOneField with attributes blank=True and null=True which is a SubKeyRing it may optionally point to. That all works

Re: OneToOneField value not selected in default html form

2008-09-10 Thread Nathaniel Griswold
Oops, i thought I was running 1.0, but i thought wrong. Thanks -nate On Wed, Sep 10, 2008 at 9:45 PM, Karen Tracey <[EMAIL PROTECTED]> wrote: > On Wed, Sep 10, 2008 at 8:21 PM, nate <[EMAIL PROTECTED]> wrote: >> >> Hi, >> >> The values of OneToOneFields don't appear to remain selected after >>

  1   2   >