Ive ran into an issue calling:
{{ modelxx.objectyy.url }}
Before some recent edits, that call gave a relative path and I used:
/site_media/{{ modelxx.objectyy.url }}
to get a full file path. After some site changes the .url gives a full
path and a double prefix of :
/home/trak/media/home/trak/
As a followup, I had to do something similar and ended up using this:
# Gets the http://domain.com without the trailing /
base_url = request.build_absolute_uri('/')[:-1]
And in the template I can do this:
...
The benefits:
-You only have to create the base_url in the view, the rest
ed on on templates. I have no
> idea how to put absolute url to my template (for
> examplehttp://domain.com/account/activate/2). I have special url for this,
> named account_activation.
> I know how to pass variables but how to create that url?
> Shouls I use {{ url }} tag? It cr
I always do something like this:
abs_activate_url =
request.build_absolute_uri(reverse('account_activate', args=user.id))
That's an absolute URL, so it's like "http://domain.com/account/
activate/2" instead of the normal reverse() or {% url %} which gives
On Nov 24, 2010, at 9:08 AM, robos85 wrote:
> What do You mean "current Site object"?
from django.contrib.sites.models import Site
current_site = Site.objects.get_current()
email_vars = Context({'registration_hash' : '123456',
'new_email' : 'm...@mail.com',
current Site object"?
On 24 Lis, 14:34, Jason Mayfield wrote:
> Pass the current Site object into the template as part of the context. Then
> you can do: {{ current_site.domain }}{% url account_activation %} for the
> absolute url.
>
> On Nov 24, 2010, at 8:16 AM, rob
Pass the current Site object into the template as part of the context. Then
you can do: {{ current_site.domain }}{% url account_activation %} for the
absolute url.
On Nov 24, 2010, at 8:16 AM, robos85 wrote:
> small correction not {{ url }} but {% url %} ?
>
> On 24 Lis, 14:01
small correction not {{ url }} but {% url %} ?
On 24 Lis, 14:01, robos85 wrote:
> Hi,
> I'm writing an email sending module based on on templates. I have no
> idea how to put absolute url to my template (for
> examplehttp://domain.com/account/activate/2). I have special url
Hi,
I'm writing an email sending module based on on templates. I have no
idea how to put absolute url to my template (for example
http://domain.com/account/activate/2). I have special url for this,
named account_activation.
I know how to pass variables but how to create that url?
Shouls
On Mar 23, 10:20 am, Bro wrote:
> Hi,
>
> django.template.defaultags exist ?
Sorry about that. I should've typed:
django.template.defaulttags
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group
Hi,
django.template.defaultags exist ?
On 20 mar, 16:36, Rajesh D wrote:
> On Mar 20, 6:16 am, Alfonso wrote:
>
>
>
> > Hi,
>
> > Insanely simple answer here I think but I'm trying to sort someurl
> > errors in a mapping app. Virtual earth requires an absoluteurlto
> > the KML file django is
On Mar 20, 6:16 am, Alfonso wrote:
> Hi,
>
> Insanely simple answer here I think but I'm trying to sort some url
> errors in a mapping app. Virtual earth requires an absolute url to
> the KML file django is generating for me and I can't seem to work out
> how t
Hi,
Insanely simple answer here I think but I'm trying to sort some url
errors in a mapping app. Virtual earth requires an absolute url to
the KML file django is generating for me and I can't seem to work out
how to define that in the urls.py. of course I can just prepend the
site r
On Sep 16, 5:42 pm, Dana <[EMAIL PROTECTED]> wrote:
> Kip, don't you mean {{ model.get_image_url }}?
>
get_FOO_url() has gone in Django 1.0.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To po
Kip, don't you mean {{ model.get_image_url }}?
Using {% url %}, get_absolute_url, MEDIA_ROOT, sites framework and
url.py should be able to accomplish what you are looking to do and
more. Also look into the permalink decorator while you're at it.
Good luck!
On Sep 16, 8:27 am, Kip Parker <[EMAIL
No, nothing to do with HTTP_HOST, that comes from the server.
The point of the sites framework is to differentiate between different
sites, so a * site would be pointless.
If I were you I'd sort out my templates so that instead of
/some/media/location/css/styles.css
you have
{{MEDIA_URL}}/css/st
Thank you Kip.
Call me stupid but does site framework have something to do with HTTP
HOST header?
But in my case the site is for ANYSITE, no matter you visit the site
by IP, domain, or even customized CNAME you cann visit the site with
out any problem (Why there isn't a wildcard * in site framew
> no, it's not THAT simple.
It really is that simple, honest, but your brain has made it all
complicated. Look at http://docs.djangoproject.com/en/dev/ref/contrib/sites/
(sites framework), TEMPLATE_CONTEXT_PROCESSORS setting and
RequestContext and the URL dispatcher docs, the answers to your
pro
On Tue, Sep 16, 2008 at 10:02 AM, est <[EMAIL PROTECTED]> wrote:
>
> Today, my boss came to me and asked: "Please move our django site from
> http://xxx.com/ to http://xxx.com/v2/";
>
> It's killing me. Just image how huge mount of HTML source code to
> modify.
> I STRONGLY suggest django implem
On 16 Sep 2008, at 9:53 am, Donn wrote:
> How about
> 1. making a link under /var/www/assets to /whatever/v2/assets
> 2. move your assets directory into /whatever/v2/
> 3. setup your webserver to go look at /var/www/assets when media is
> served.
>
> You should be able to arrange something lik
On Tuesday, 16 September 2008 10:32:54 est wrote:
> http://xxx.com/assets/main.css
> Now the problem is, how can I massively move all template under a new
> sub-directory URL like http://xxx.com/v2/ ?
How about
1. making a link under /var/www/assets to /whatever/v2/assets
2. move your assets dire
y root (/) is not domain dependent (use sites
> framework for settings domain name).
>
> --
> We read Knuth so you don't have to. - Tim Peters
>
> Jarek Zgoda, R&D, Redefine
> [EMAIL PROTECTED] Hide quoted text -
>
> - Show quoted text -
no, it's not T
Seems like you have a lot of URLs hardcoded -- you shouldn't do that.
Use MEDIA_URL for static media files and the {% url %} tag for dynamic
URLs (or django.core.urlresolvers.reverse in Python code).
Erik
On 16.09.2008, at 11:02, est wrote:
>
> Today, my boss came to me and asked: "Please m
The domain isn't changing. It's just the path, so links that use
absolute paths will break. In a way I get it - using relative urls is
easy to break something if you need to move it. Also copy & paste
becomes hard. Perhaps an APPNAME_URL in your request context would
help?
Tim ^,^
2008/9/16 Ja
Isn't that what MEDIA_URL is for? At least for your images and css
resources. And as for the rest of the urls... urls.py?
Tim ^,^
On Tue, Sep 16, 2008 at 9:02 AM, est <[EMAIL PROTECTED]> wrote:
>
> Today, my boss came to me and asked: "Please move our django site from
> http://xxx.com/ to htt
Wiadomość napisana w dniu 2008-09-16, o godz. 10:02, przez est:
>
> Today, my boss came to me and asked: "Please move our django site from
> http://xxx.com/ to http://xxx.com/v2/";
>
> It's killing me. Just image how huge mount of HTML source code to
> modify.
>
> I STRONGLY suggest django implem
Today, my boss came to me and asked: "Please move our django site from
http://xxx.com/ to http://xxx.com/v2/";
It's killing me. Just image how huge mount of HTML source code to
modify.
I STRONGLY suggest django implement a 'project url' like asp.net, say
where ~ always points to the current d
Hi Florian,
Florian Lindner wrote:
> Hello,
>
> how can I get an absolute URL including a hostname (e.g.
> http://www.example.org/dir/doc.html)
> in a template. I have an object which get_absolute_url I can use but
> what is the best way of getting the hostname in the t
On Sun, 2008-07-06 at 15:21 +0200, Florian Lindner wrote:
> Hello,
>
> how can I get an absolute URL including a hostname (e.g.
> http://www.example.org/dir/doc.html)
> in a template. I have an object which get_absolute_url I can use but
> what is the best way of getti
Hello,
how can I get an absolute URL including a hostname (e.g.
http://www.example.org/dir/doc.html)
in a template. I have an object which get_absolute_url I can use but
what is the best way of getting the hostname in the template?
Thanks,
Florian
I read that doc many times :)
Missed that little detail every time though.
Thanks for the help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@g
c (
http://www.djangoproject.com/documentation/settings/#absolute-url-overrides)
says this is a mapping of ''"app_label.model_name" strings'. App_label, I
believe, is only the rightmost part of the Python path to the application
(in this case django.contrib.auth, so for rig
ABSOLUTE_URL_OVERRIDES = {
'django.contrib.auth.models.user': lambda o: "/members/%s/" %
o.username,
}
Doesn't seem to be working, any idea why?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" grou
Mon, 2008-03-31 at 01:01 -0700, jurian wrote:
> > Is there any way apart from the following to get the absolute URL of
> > an object?
>
> There is no canonical "absolute URL" for an object. It's one of the
> things you define (in the get_absolute_url() method o
On Mon, 2008-03-31 at 01:01 -0700, jurian wrote:
> Is there any way apart from the following to get the absolute URL of
> an object?
There is no canonical "absolute URL" for an object. It's one of the
things you define (in the get_absolute_url() method of the model). So
th
Is there any way apart from the following to get the absolute URL of
an object?
opts = model._meta
url = "../../../%s/%s/add/" % (opts.app_label.lower(),
opts.object_name.lower())
--~--~-~--~~~---~--~~
You received this message because you are subscri
You were quite right, Wayne, there was a mistake in my model (Charfield
instead of SlugField)...so don't I feel stupid!
A million thanks to everyone anyway!
(I feel quite well qualified to write an idiot's guide now...)
--~--~-~--~~~---~--~~
You received this me
This isn't working for you?
{% for organisation in object.organisation_set.all %}
{{
organisation.org_name }}
{% endfor %}
If the name works, but not get_absolute_url I'd say you have something
wrong with your model. Open a shell and play with you model to make
sure everything is wor
In other words, why can't I simply put
{{organisation.get_absolute_url}}
to return the organisation's detail page?
Surely the whole point of the get_absolute_url is to be able to call an
object from wherever?
So what would I put in the model and/or urls.py to be able to do this?
At the moment I
Mmm...I actually got it to work in the category_detail template:
{% for organisation in object.organisation_set.all %}
{{organisation.org_name}}
{% endfor %}
Each category does return a list of the organisations that are in it,
but what I need to do is then simply provide access to
On 12/13/06, conrad22 <[EMAIL PROTECTED]> wrote:
>
> Yes, I know. Sorry, should have been more specific:
> the problem is, that the second part of the url pattern comes from a
> different model.
>
> I've tried
> (r'^categories/(?P\d+)/(?P\w+)/$','django.views.generic.list_detail.object_detail',
>
Yes, I know. Sorry, should have been more specific:
the problem is, that the second part of the url pattern comes from a
different model.
I've tried
(r'^categories/(?P\d+)/(?P\w+)/$','django.views.generic.list_detail.object_detail',
info_dict),
but it's obviously not quite there...? How would I
On Tue, Dec 12, 2006 at 11:13:52AM -0800, conrad22 wrote:
>
> Woops..see, I am already mad, as I have not communicated the actual
> problem..
>
> The last bit - 'categories/1/k/' returns a page/url not found error,
> as follows:
>
> Request Method: GET
> Request URL: http://127.0.0.
Woops..see, I am already mad, as I have not communicated the actual
problem..
The last bit - 'categories/1/k/' returns a page/url not found error,
as follows:
Request Method: GET
Request URL:http://127.0.0.1:8000/categories/1/k/
Using the URLconf defined in kvn.urls, Django tri
Hi
Hopefully someone can step in here before I go totally mad...
I am trying to define the absolute_url and/or the urls.py file to
arrive at the following:
A list of categories, which leads to a list of organisations in each
category.
I want then each organisation in the list to go to its generi
45 matches
Mail list logo