django-sites

Is there a way to add fields onto Django's Sites Framework?

不打扰是莪最后的温柔 提交于 2020-01-04 07:00:28
问题 I really like the idea of the sites framework for making an application functional across multiple web sites. Is there a way to add fields onto the Site object for the database, or should I just create a foreign-key one-to-one relationship? 回答1: Yes, use a model with a unique foreign key. Django will add it to Site as a reverse relationship. 来源: https://stackoverflow.com/questions/6892198/is-there-a-way-to-add-fields-onto-djangos-sites-framework

How can I get the Django admin's “View on site” link to work?

给你一囗甜甜゛ 提交于 2019-12-20 12:15:09
问题 I've been working with a Django app for a while, and the Django admin interface works great, except that the "View on site" link doesn't work. Whenever I try to use it, I get an OperationalError with the message: no such table: django_site . I've done some research into this problem, and it seems that I have to set up the Django sites framework for this link to work, but I'm exactly sure how to do that. The documentation talks about database tables, etc., but it doesn't tell how to actually

Different database for each django site

纵饮孤独 提交于 2019-12-20 03:03:30
问题 Suppose we have multiple sites (using sites-framework of Django) running on the same django instance. MyModel.objects.filter(site_id=request.site, slug=slug)[0] might be an overhead in the future. So I was wondering if I could split the databases for this model(s) for querying faster. So if request.site is 1, running MyModel.objects.get(slug=slug) will query only db1. If request.site is 2, running MyModel.objects.get(slug=slug) will query only db2. I will be getting request.site from the

call a method in Django admin site

佐手、 提交于 2019-12-11 20:59:16
问题 i have a Django project and right now everything works fine. i have a Django admin site and now, i want that when i add a new record to my model, a function calls simultaneously and a process starts. how i can do this? what is this actions name? 回答1: 1 WAY You can go to your models.py into your app by using django signal you can do this. from django.db.models.signals import post_save class Test(models.Model): # ... fields here # method for updating def update_on_test(sender, instance, *

Is it possible to use the Django Sites Framework with multiple Sites on the same instance?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 10:49:49
问题 I have defined multiple sites as the documentation of the Site Framework suggested. I understand that if I would run mulitple instances of my application with each of them having a different settings file (different SITE_ID), Django would always know which Site to use. What I was trying to do is to run a single instance, where multiple sites are available, and the right Site should be chosen depending on the current url of the site. The Sites documentation states: The SITE_ID setting

Django 1.7 multisite User model

自闭症网瘾萝莉.ら 提交于 2019-12-07 00:53:29
问题 I want to serve a Django application that serves multiple web sites by single database but different user sets. Think like a blog application, it will be used by several domains with different themes, but use same database by adding a site field to models. I use Django's SitesFramework for that job. But the problem is, I couldn't separate user models for different sites. I want to use same user model with a site field and email field that unique per site. I tried to extend AbstractUser model

Is it possible to use the Django Sites Framework with multiple Sites on the same instance?

余生长醉 提交于 2019-12-06 05:28:31
I have defined multiple sites as the documentation of the Site Framework suggested. I understand that if I would run mulitple instances of my application with each of them having a different settings file (different SITE_ID), Django would always know which Site to use. What I was trying to do is to run a single instance, where multiple sites are available, and the right Site should be chosen depending on the current url of the site. The Sites documentation states: The SITE_ID setting specifies the database ID of the Site object associated with that particular settings file. If the setting is

Django 1.7 multisite User model

戏子无情 提交于 2019-12-05 05:02:45
I want to serve a Django application that serves multiple web sites by single database but different user sets. Think like a blog application, it will be used by several domains with different themes, but use same database by adding a site field to models. I use Django's SitesFramework for that job. But the problem is, I couldn't separate user models for different sites. I want to use same user model with a site field and email field that unique per site. I tried to extend AbstractUser model like that: from django.contrib.auth.models import AbstractUser from django.contrib.sites.models import

How can I get the Django admin's “View on site” link to work?

穿精又带淫゛_ 提交于 2019-12-03 02:28:46
I've been working with a Django app for a while, and the Django admin interface works great, except that the "View on site" link doesn't work. Whenever I try to use it, I get an OperationalError with the message: no such table: django_site . I've done some research into this problem, and it seems that I have to set up the Django sites framework for this link to work, but I'm exactly sure how to do that. The documentation talks about database tables, etc., but it doesn't tell how to actually set up a site. So my question is really two-fold: How do I get the sites framework set up? Do I have to

Different database for each django site

懵懂的女人 提交于 2019-12-02 01:06:32
Suppose we have multiple sites (using sites-framework of Django) running on the same django instance. MyModel.objects.filter(site_id=request.site, slug=slug)[0] might be an overhead in the future. So I was wondering if I could split the databases for this model(s) for querying faster. So if request.site is 1, running MyModel.objects.get(slug=slug) will query only db1. If request.site is 2, running MyModel.objects.get(slug=slug) will query only db2. I will be getting request.site from the request parameter of the view as value of site will be dynamically determined according to the subdomain