2๐
โ
I think you should have a look at the django.contrib.sites
models, which are there for precisely the problem you are trying to solve โ have multiple subdomain and domain represented by the content.
Quoting the example mentioned there:
from django.db import models
from django.contrib.sites.models import Site
class BlogEntry(models.Model):
headline = models.CharField(max_length=200)
text = models.TextField()
# ...
sites = models.ManyToManyField(Site)
๐คAnshul Goyal
1๐
From a DB design standpoint you should move the lang
field to an own model and reference it from the BlogEntry.
class Language(models.Model):
lang = models.CharField(max_length="2")
class BlogEntry(models.Model):
text = models.TextField()
lang = manufacturer = models.ForeignKey('Language')
That way you can change the actual name of the language by updating a single record and not multiple. However, if you are sure that this will never you can also stick with your approach.
๐คMartin Thurau
- [Django]-How to filter generic foreign keys?
- [Django]-Display sql query to create django model object
- [Django]-Received a naive datetime while time zone support is active
- [Django]-How do I set the from_email var
Source:stackexchange.com