2

I created a project say foo. And created an app named admin. But it causes an error

django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin”

So I read this and made changes as mentioned there. I marked the label as foo.admin.
I don't exactly know what the label is, but maybe this is the unique name given to an app to distinguish apps with the same name in case.
So is that mean, everywhere I have to use label instead of name?
But it causes another error.
String model references must be of the form 'app_label.ModelName'.
So I used the name in models as foo.admin in ForeignKey parameter. But the same error comes up. But the error persists.
I googled the error and found this. So I changed the ForeignKey parameter from foo.admin to admin. But in either case, I'm having this error.

So in short I want to ask

How to use apps with the same name in the same django project, like Which files are need to be modified and what to write ForeignKey parameters etc.?

(I'm using django 2.0)

Dead Pool
  • 133
  • 2
  • 9
  • have you tried to use a valid Python identifier (without dots) as a label? https://docs.djangoproject.com/en/2.0/ref/applications/#django.apps.AppConfig.label – emulbreh Mar 31 '18 at 14:08
  • I tried with `foo_admin` admin also. Then it is showing that 'foo_admin' app is not found something error. – Dead Pool Mar 31 '18 at 15:17
  • You need to follow the solution in the [linked answer](https://stackoverflow.com/questions/24319558/how-to-resolve-django-core-exceptions-improperlyconfigured-application-labels/24319562#24319562). That let's you override the app label. To make your ForeignKeys work, you should only need to pick a label that doesn't contain dots. – emulbreh Mar 31 '18 at 18:25
  • I tried label as `siraj_admin` but still it didn't work. – Dead Pool Apr 07 '18 at 11:12

0 Answers0