Hi,
I would like to implement multicolumns primary keys in django, i need to
implement a UserPro model that allow that i have a multiple users who have
the same username but belong to different Entreprise
this is my code
#models.py
from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
class Provider(models.Model):
name = models.CharField(max_length=250)
adress = models.CharField(max_length=250)
def __unicode__(self):
return '%s %s' % (self.name, self.adress)
class Societe(models.Model):
name = models.CharField(max_length=250)
provider = models.ForeignKey(Provider)
def __unicode__(self):
return '%s -- %s' % (self.name, self.provider.name)
class UserPro(models.Model):
user = models.OneToOneField(User,primary_key=True)
adress = models.CharField(max_length=250)
telephone = models.CharField(max_length=250)
societe = models.ForeignKey(Societe,primary_key=True)
def __unicode__(self):
return '%s' % (self.user.first_name)
#admin.py
from django.contrib import admin
from geo.models import *
admin.site.register(UserPro)
admin.site.register(Societe)
admin.site.register(Provider)
--
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.
For more options, visit https://groups.google.com/groups/opt_out.