Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customization with Migration #200

Closed
maxillosoft-dimitry opened this issue Mar 18, 2022 · 1 comment
Closed

Customization with Migration #200

maxillosoft-dimitry opened this issue Mar 18, 2022 · 1 comment
Labels
duplicate A similar issue or PR already exists

Comments

@maxillosoft-dimitry
Copy link

I read the documentation and created similar customization such as:

organizations/models.py

from django.db import models
from rest_framework_api_key.models import AbstractAPIKey

class Organization(models.Model):
name = models.CharField(max_length=128)
active = models.BooleanField(default=True)

class OrganizationAPIKey(AbstractAPIKey):
organization = models.ForeignKey(
Organization,
on_delete=models.CASCADE,
related_name="api_keys",
)

class OrganizationAPIKey(AbstractAPIKey):
some code specific to the project
class Meta(AbstractAPIKey.Meta):
verbose_name = "Organization API key"
verbose_name_plural = "Organization API keys"

When I run ./manage.py migrate rest_framework_api_key, I thought it should only create the OrganizationAPIKey table but it also creates the rest_framework_api_key_apikey table in mysql. On https://docs.djangoproject.com/en/2.2/topics/db/models/#abstract-base-classes, it says that abstract classes do not get created when class Meta: abstract = true and I see that in the AbstractAPIKey class.

Any ideas what I am doing wrong?

Thanks
-Dimitry

@florimondmanca
Copy link
Owner

Hi @maxillosoft-dimitry, I believe this is related - if not a duplicate - of #180.

At the time:

Feel free to read through this issue and see if that corresponds to your use case. For now I am tentatively closing this. Thanks!

@florimondmanca florimondmanca added the duplicate A similar issue or PR already exists label Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate A similar issue or PR already exists
Projects
None yet
Development

No branches or pull requests

2 participants