OO in Django

47 views
Skip to first unread message

Eduardo Basílio

unread,
Jun 23, 2014, 10:18:15 AM6/23/14
to django...@googlegroups.com

Hello, 
Can you help me on a question OO in Django?

How the Transaction class can reference Person or Corporation? 
* Customer is an abstract class


Django_ForeignKey.jpg

Ricardo Daniel Quiroga

unread,
Jun 23, 2014, 12:11:34 PM6/23/14
to django...@googlegroups.com
Hi
mmmm I think I would do as follows :P

#models.py code

class Customer(model.Model):
    ***

class Transation(model.Model):
     ***
     customer = models.ForeignKey(Customer)


class Person(Customer):
      ***    

class Corporation(Customer):
      ***

*** you object atributes


--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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/26474e7c-f79e-416b-8569-9edb689dc191%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
------------------------------------------------------------
Ricardo Daniel Quiroga - L2Radamanthys

   Msn: l2rada...@gmail.com
           ricard...@hotmail.com

   Email: l2rada...@gmail.com
           l2rada...@saltalug.org.ar
           ricardoqu...@gmail.com
 
   sitio Web: http://www.l2radamanthys.com.ar
                   http://github.com/L2Radamanthys
   Twitter:    @l2Radamanthys
---------------------------------------------------------

Mario Gudelj

unread,
Jun 23, 2014, 3:02:17 PM6/23/14
to django...@googlegroups.com
Ricardo is correct. But make sure you use abstract model for Customer in this case. I use the AbstractUser a lot because in most cases the customers need to be system users and have a log in etc.


Reply all
Reply to author
Forward
0 new messages