Django Admin's “view on site” points to example.com instead of my domain

后端 未结 6 939
一生所求
一生所求 2020-12-15 04:37

I added a get_absolute_url function to one of my models.

def get_absolute_url(self):
    return \'/foo/bar\' 

The admin site p

6条回答
  •  长情又很酷
    2020-12-15 05:10

    As others have mentioned, this is to do with the default sites framework.

    If you're using South for database migrations (probably a good idea in general), you can use a data migration to avoid having to make this same database change everywhere you deploy your application, along the lines of

    from south.v2 import DataMigration
    from django.conf import settings
    
    class Migration(DataMigration):
    
        def forwards(self, orm):
            Site = orm['sites.Site']
            site = Site.objects.get(id=settings.SITE_ID)
            site.domain = 'yoursite.com'
            site.name = 'yoursite'
            site.save()
    

提交回复
热议问题