Daniel,
I didn't include any code as I didn't do anything unusual but if you think
that would help here it is.I was hoping that there was some ordinary
theoretical basis for this as I didn't do anything custom really, aside
from the id generation for the "Entity" class, which I generate the id
manually much like an Oracle sequence object, I do this in order to
facilitate the creation of relationships between arbitrary objects.
Any help is appreciated
***********models******************************
def get_entity_id():
# try:
db = mysql.connect(host="localhost", user="root", passwd="jerryklein",
db="entities")
db.query("insert entities_entityid (fake) select ' '")
id = db.insert_id()
return id
class Entity(models.Model):
""" the fName field is also the company name field """
id = models.BigIntegerField(primary_key=True, unique=True,
default=get_entity_id())
fName = models.CharField(max_length=255, blank=True, null=True)
lName = models.CharField(max_length=255)
entityType = models.ForeignKey(EntityType)
class Meta:
verbose_name = "Entity"
verbose_name_plural = "Entities"
def __unicode__(self):
return "{0} {1}".format(self.fName, self.lName)
class Address(models.Model):
addressType = models.ForeignKey(AddressType)
entity = models.ForeignKey(Entity)
add1 = models.CharField(max_length=50)
add2 = models.CharField(max_length=50, blank=True, null=True)
city = models.CharField(max_length=50)
postalCode = models.CharField(max_length=50)
class Meta:
verbose_name = "Address"
verbose_name_plural = "Addresses"
def __unicode__(self):
return "{0},{1},{2},{3},{4},{5}".format(self.addressType,
self.add1, self.add2, self.city, self.postalCode)
class State(models.Model):
name = models.CharField(max_length=50)
abrev = models.CharField(max_length=50)
class Meta:
verbose_name = "State"
verbose_name_plural = "States"
def __unicode__(self):
return "{0}".format(self.name)
class Country(models.Model):
name = models.CharField(max_length=50)
class Meta:
verbose_name = "Country"
verbose_name_plural = "Countries"
def __unicode__(self):
return "{0}".format(self.Name)
class ForeignAddress(Address):
province = models.CharField(max_length=50)
country = models.ForeignKey(Country)
class Meta:
verbose_name = "Foreign Address"
verbose_name_plural = "Foreign Addresses"
def __unicode__(self):
return "{0},{1},{2},{3},{4},{5}".format(self.add1, self.add2,
self.city, self.postalCode, self.province,
self.country)
class USAddress(Address):
state = models.ForeignKey(State)
class Meta:
verbose_name = "Address"
verbose_name_plural = "Addresses"
def __unicode__(self):
return "{0},{1},{2},{3},{4},{5}".format(self.addressType,
self.add1, self.add2, self.city, self.state, self.postalCode)
***************below is admin classes*********************************
class AddressTypeAdmin(admin.ModelAdmin):
list_display = ('name', 'description', )
ordering = ('name', )
admin.site.register(AddressType, AddressTypeAdmin)
class USAddressAdmin(admin.TabularInline):
actions = ['delete_selected']
model = USAddress
extra = 1
class ForeignAddressAdmin(admin.TabularInline):
model = ForeignAddress
extra = 1
class EntityAdmin(admin.ModelAdmin):
inlines = [USAddressAdmin, ForeignAddressAdmin]
list_display = ('fName', 'lName', 'entityType')
ordering = ('lName', )
exclude = ['id']
admin.site.register(Entity, EntityAdmin)
On Mon, Dec 15, 2014 at 3:54 AM, Daniel Roseman <[email protected]>
wrote:
>
> On Monday, 15 December 2014 00:53:05 UTC, Gerald Klein wrote:
>>
>> HI, I have a simple contact form with an address subform in the form of
>> "TabularInline" where you can add an arbitrary amount of addresses, after I
>> add a contact and an address and save, when I go to add a brand new contact
>> and address, the address that I just added will be there and if I add the
>> new contact it will over write not only the address but contact I added
>> previously, so it is keeping the entire record and updating it. It won't
>> fix itself until I stop the django server and start it again. Then I can do
>> the whole thing again with a new record.
>>
>> I appreciate any that someone can give, thanks
>>
>> --
>>
>> Gerald Klein DBA
>>
>
> Nobody can help you if you don't show any code.
> --
> DR.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bdaf77eb-7862-428b-923f-bb4c44c5dad0%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/bdaf77eb-7862-428b-923f-bb4c44c5dad0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
Gerald Klein DBA
[email protected]
www.geraldklein.com
<http://t.senalcinco.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XZs1p1kmsW3N1NWP1p8b8gW3LPXXH56dyQSf6HGzv402?t=http%3A%2F%2Fgeraldklein.com%2F&si=5404167384858624&pi=273ff117-0b5e-4ac8-d90f-5374a47678e0>
geraldklein.wordpress.com
<http://t.senalcinco.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XZs1p1kmsW3N1NWP1p8b8gW3LPXXH56dyQSf6HGzv402?t=http%3A%2F%2Fgeraldklein.wordpress.com%2F&si=5404167384858624&pi=273ff117-0b5e-4ac8-d90f-5374a47678e0>
[email protected]
708-599-0352
<http://t.senalcinco.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XZs1p1kmsW3N1NWP1p8b8gW3LPXXH56dyQSf6HGzv402?t=&si=5404167384858624&pi=273ff117-0b5e-4ac8-d90f-5374a47678e0>
Arch, Gentoo I3, Ranger & Vim the coding triple threat.
Linux registered user #548580
Brought to you by the Amish Mafia
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAP8NtCxwL8N2-x4zXrciVo-zYOrJfP6AzKursm47fDx_bSGb2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.