django-inheritance

Subclassing AbstractUser in Django for two types of users

你说的曾经没有我的故事 提交于 2019-12-04 21:23:32
I'm developing a school database system in Django 1.5, and was planning on having a number of different user types (Student, Staff, Parent) which subclass AbstractUser (actually, another abstract subclass of AbstractUser). I was just attempting to add an externally developed app to my system, which uses User in a ForeignKey for some of its models, however, this fails as my user type is not a 'User' instance. I can't set the apps models to use AbstractUser as one can't use abstract classes for Foreign Keys. I was then considering adding to my settings.py AUTH_USER_MODEL = 'myapp.MyUser' and

seperate 'admin' interfaces for different user types in django

核能气质少年 提交于 2019-12-03 15:55:47
I have recently being trying to create a project which has several levels of user involved. (Just an example of an abbreviated and rough schema) ME (Super User) Client (s) Customer (s) Survey Collections SurveyUser (s) Invitee (s) Surveys Invitee (s) (invitee is a child of both survey and user) Questions Etc I would ideally have: www.example.com/client/ go to a client interface which you had to be a client to access www.example.com/customer/ go to a customer interface which you had to be a customer to access I have already established that using a customised Django admin interface for all of

Determining Django Model Instance Types after a Query on a Base-class

大兔子大兔子 提交于 2019-11-29 09:44:24
Is there a way to determine what the 'real' class of a Django database object is, after it has been returned from a query for on a base class? For instance, if I have these models... class Animal(models.Model): name= models.CharField(max_length=128) class Person(Animal): pants_size = models.IntegerField(null=True) class Dog(Animal): panting_rate = models.IntegerField(null=True) And create these instances... Person(name='Dave').save() Dog(name='Mr. Rufflesworth').save() If I do a query like Animal.objects.all() , I end up with two Animal instances, not an instance of Person and an instance of

Determining Django Model Instance Types after a Query on a Base-class

倖福魔咒の 提交于 2019-11-28 02:57:48
问题 Is there a way to determine what the 'real' class of a Django database object is, after it has been returned from a query for on a base class? For instance, if I have these models... class Animal(models.Model): name= models.CharField(max_length=128) class Person(Animal): pants_size = models.IntegerField(null=True) class Dog(Animal): panting_rate = models.IntegerField(null=True) And create these instances... Person(name='Dave').save() Dog(name='Mr. Rufflesworth').save() If I do a query like

In Django - Model Inheritance - Does it allow you to override a parent model's attribute?

两盒软妹~` 提交于 2019-11-26 15:21:15
I'm looking to do this: class Place(models.Model): name = models.CharField(max_length=20) rating = models.DecimalField() class LongNamedRestaurant(Place): # Subclassing `Place`. name = models.CharField(max_length=255) # Notice, I'm overriding `Place.name` to give it a longer length. food_type = models.CharField(max_length=25) This is the version I would like to use (although I'm open to any suggestion): http://docs.djangoproject.com/en/dev/topics/db/models/#id7 Is this supported in Django? If not, is there a way to achieve similar results? Updated answer: as people noted in comments, the

In Django - Model Inheritance - Does it allow you to override a parent model's attribute?

▼魔方 西西 提交于 2019-11-26 05:58:15
问题 I\'m looking to do this: class Place(models.Model): name = models.CharField(max_length=20) rating = models.DecimalField() class LongNamedRestaurant(Place): # Subclassing `Place`. name = models.CharField(max_length=255) # Notice, I\'m overriding `Place.name` to give it a longer length. food_type = models.CharField(max_length=25) This is the version I would like to use (although I\'m open to any suggestion): http://docs.djangoproject.com/en/dev/topics/db/models/#id7 Is this supported in Django?