the example.com is am example django give for Site. Which means there is a
way for you to manage more than one site at a time, basically using the
site_id.
To you Questions, i don't understand why you want to hard code your uri
routing like that when you can easily use the app_name and name convention
which is more dynamic then hard coding it like that:
for example at the model Transaction urls.py
app_name = "trans"
url(r'(?P-/d+)$', views.func, name='account_trans'),
def get_absolute_url(self):
return reverse("trans:account_trans", kwargs={"pk":self.pk})
and you will be just fine hope this help
On Sunday, June 10, 2018 at 12:30:51 PM UTC+1, Joakim Hove wrote:
>
> Hello,
>
> I have a model `Transaction` which can be viewed at the url:
> /transaction/view/$ID/ - if I just enter that url in the browser, or in
> template everything works. But when I have the following get_abolute_url()
> method:
>
> def get_absolute_url(self):
> return "/transaction/view/{}/".format( self.id )
>
> things do not work from the Admin. When I click on the "View on Site" link
> i am redirected to "http://example.com/transaction/view/23635/; and I get
> an error message about failed XML parsing. I have no clue where the "
> example.com" address comes from - that string is not in my codebase. If I
> hardcode the get_absolute_url to:
>
> def get_absolute_url(self):
> return "http://127.0.0.1:8000/transaction/view{}/".format(self.id)
>
> That works in development, but needless to say that is not a very good
> approach.
>
> I am on Django 1.10
>
>
> Regard Joakim
>
>
>
--
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/5678b297-2693-4ae8-b249-08e42713ebf7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.