You can try something like below:
  class CustomSiteManager(CurrentSiteManager):

    def get_queryset(self):
        current_site = Site.objects.get_current()
        return super(CustomSiteManager, self).get_queryset().filter(
            **{self._get_field_name() + '__id': current_site.id})


We are trying to extend the CurrentSiteManager and slightly modified the method 
get_queryset. By using this way no need to set SITE_ID in settings.


We need to refer CustomSiteManager instead of CurrentSiteManager in all of your 
models.




On Tuesday, March 22, 2016 at 8:51:41 PM UTC+5:30, [email protected] wrote:
>
> But if I don't set the SITE_ID in settings.py I can't use the 
> CurrentSiteManager, correct?
>
>
> On Tuesday, March 22, 2016 at 1:33:39 PM UTC+1, Sai Kiran wrote:
>>
>> If you need to use single projects for more than domains, create an entry 
>> in django_site model by giving domain as well as verbose name. Don't give 
>> any SITE_ID in settings.py, instead of this you can use 
>> Site.objects.get_current() in your view and compare the domain names and 
>> change the header accordingly.
>>
>> Please feel free to correct me if I'm wrong.
>>
>>
>> On Tuesday, March 22, 2016 at 6:38:27 AM UTC+5:30, [email protected] 
>> wrote:
>>>
>>> I'm wondering if I understand the Sites framework correctly... I'm 
>>> building a forum-like project which will initially be accessible from 
>>> mydomain.com . The project contains several apps like posts, members, 
>>> ads, etc. Eventually I would like to create myseconddomain.com, which 
>>> would have unique posts, but share the members, ads, etc. apps and look the 
>>> same as the first site except for the domain name and title in the header. 
>>> The code will be identical to the first site. Can I achieve this with a 
>>> single project and several SITE_IDs, or am I correct in thinking that the 
>>> Sites framework is only for sharing the same database across projects, and 
>>> not the code files? And if there is a way to share the code files, how do 
>>> you get around the fact that you set SITE_ID once in settings.py?
>>>
>>> Thanks in advance for the help!
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b7c89f05-5376-4b62-a0f1-c44666cd8406%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to