On Tuesday 24 January 2017 11:14:58 Tim Graham wrote: > Correct, you shouldn't declare class QuestionAdmin(...) twice. What > problem do you see if you combine those classes? It's unlikely > related to your Python version. > > On Tuesday, January 24, 2017 at 10:45:50 AM UTC-5, John Wall wrote: > > I'm guessing you mean that I have to class calls for QuestionAdmin?
Note that Tim calls it "declare" and you call it "calls". Not being pedantic, but it's the key to understanding your mistake: You can only declare something once in the same scope. You can call it as many times as you want. The scope is also important: class Awesome(models.Model): name = models.CharField(max_length=200) def awesome_factory(unique=False): class Awesome(models.Model): name = models.CharField(max_length=200, unique=unique) class Meta: abstract = True return Awesome class TheBomb(awesome_factory(unique=True)): pass class Magnificent(awesome_factory()): pass As you see, I declared two Awesome classes, but the second is in the scope of the awesome_factory function - so this works. The result is that in the outer scope Awesome and Magnificent are identical models with a different name and that TheBomb has a name field that enforces uniqueness. Hope this sheds some light on things :) -- Melvyn Sopacua -- 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 post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2242474.KXECURW2MG%40devstation. For more options, visit https://groups.google.com/d/optout.