Once again, if you don't have a default site_id or the request object available inside the method, then what do you expect it to return? I'm not asking programatically, but logically,
If you only care about the template the you can concatenate the domain and the absolute path in the template itself {{ domain }}{{ ob.get_absolute url }} where the absolute url is something like '/model/5' or something like that, without the domain. On 1/13/17, Max <kiselev...@gmail.com> wrote: > Vijay Khemlani, i think my question have not a lot of details. More > 1) Django site framework (works with request.get_host() without Site_id). > I can get the current site with Site.objects.get_current(*request*), > shortcuts (get_current_site) or through model. But i have only one model > with site relationship. > > 2) Django class-based view. > > 3) For example, template > >> {{obj.get_url}} <- error Site does not exists [set site_id or use 1)] > > > Model > class Model(models.Model): > def get_absolute_url(self): > > return 'http://{}{}'.format(Site.objects.get_current(????).domain, > reverse(viewname='product', > args=[self.slug])) > > > Thanks, also i do not want to change site_id dynamically (thread) or use > site through model-model. > > -- > 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 django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > 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/32ee2f28-8d2b-4a14-ba87-c6150fd88399%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. 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/CALn3ei1Sj4%3DEu-pzWa5RKbi%3DfDVhX3%2B6byNESqYeN%3DvUz4WBYw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.