Re: Template problem

2012-07-17 Thread Eli_West
why I posted this question, i dont know plz help lol

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/m68NaOa1yXoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: serve media and static separately for development

2012-07-17 Thread Eli_West
Example / recommended procedure for devel edit url.conf like this:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/home/blah/media'}),


And have all media and static files in there. I want to be able to serve 
multiple locations and avoid having to replace /site_media/  with {{ 
STATIC_URL }} all throughout my code once it goes to prod.

thx



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hyob1b1kc7YJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



serve media and static separately for development

2012-07-17 Thread Eli_West
I like the recent move using collect static and splitting up static files 
(css js ect) and media files. But for development they still have 
everything clumped into site_media, the docs don't recommend splitting this 
up (why). I want to have my code ready to go when I switch to prod so I'm 
using {{ STATIC_URL }} and {{MEDIA_URL}} right away.

Anyone have examples they are using to server both locations in development?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WyFkrQNiuYIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Working Hello World Ajax example via django pleeeease

2012-04-13 Thread Eli_West
Thanks. I found another example that used get() and didn't seem to
work for me either:

http://mitchfournier.com/tag/ajax/

I guess I want an example that is simple as possible so I can try and
find where the issue it occuring. I'll try your example later today.

On Apr 13, 4:12 am, Joey Espinosa <jlouis.espin...@gmail.com> wrote:
> Btw, disregard what I said about mixing URL and CSS selectors. I forgot
> that load() can do that (I usually use ajax() or get()/post(), neither of
> which supports that). MY BAD!
>
> --
> Joey Espinosa
> Software Engineerhttp://about.me/joelinux
> On Apr 13, 2012 6:05 AM, "Joey Espinosa" <jlouis.espin...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Daniel is right. The only way your code will work is if you've set up your
> > argument to load() to be caught by urls.py.
>
> > Also, in your case, it seems like your argument to load() is a mix of URL
> > and CSS selector... Make sure you're using a URL there.
>
> > Check out my blog for a very basic tutorial on getting AJAX to work in
> > Django:
>
> >http://joelinux117.blogspot.com/2011/11/making-ajax-calls-in-django-u...
>
> > It's using Dojo, but the same principle applies with jQuery (just make
> > sure where the tutorial calls a URL, you're passing the URL as an argument
> > to load().
>
> > --
> > Joey Espinosa
> > Software Engineer
> >http://about.me/joelinux
> > On Apr 13, 2012 5:39 AM, "Daniel Roseman" <dan...@roseman.org.uk> wrote:
>
> >> On Friday, 13 April 2012 08:08:19 UTC+1, Eli_West wrote:
>
> >>> I've been attempting the most basic ajax call (.load()  )  through
> >>> django for over a month now - each time trying a different method or
> >>> tutorial none with success. Can someone post a working paradigm for
> >>> whatever django csrf, firefox, ect. workaround they use?
>
> >>> I can get jquery .load() to load content from an external file with
> >>> static files , no django. Same file served through django/templating
> >>> and the ajax is blocked. This is the general jquery call:
>
> >>> $(document).ready(function() {
> >>>     $('.list').click(function () {
> >>> $('#message').load('namesinfo.**htm li');
> >>>         return false;
> >>>     });
> >>> });
>
> >>> To make things worse I found that Firefox/Chrome breaks Jquery's
> >>> sample 'Tabs: load content via ajax'  in the Themroller download. But
> >>> it works in IE :/. Same .load() calls occuring here. Just working w
> >>> static files no django. Could it be related to Firefox/Chrome?
>
> >>> I am pretty sure it is not: static file serving issues. I have heard
> >>> comments to follow django 'csrf / ajax' and included their sameOrgin
> >>> script to no avail. :
>
> >>>https://docs.djangoproject.**com/en/dev/ref/contrib/csrf/<https://docs.djangoproject.com/en/dev/ref/contrib/csrf/>
>
> >>> A similar issue even though this guys solution is hard to understand:
>
> >>>http://stackoverflow.com/**questions/6643242/jquery-load-**
> >>> not-working-in-django<http://stackoverflow.com/questions/6643242/jquery-load-not-working-in...>
>
> >> The argument to `load` is the URL you want to load. If you want that to
> >> be served by Django, you need to pass in a URL that's handled by your
> >> Django urls.py. 'namesinfo.**htm' seems unlikely to be a Django url.
> >> --
> >> DR.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To view this discussion on the web visit
> >>https://groups.google.com/d/msg/django-users/-/3CzEsK5NobAJ.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Working Hello World Ajax example via django pleeeease

2012-04-13 Thread Eli_West
Thanks, I tried to stay clear of posting code because I've tried maybe
20 different ways and nothing seems to work. I have used the {% url %}
tag and yesterday competed - a 'ajax_user_search' tut using django Q
still no luck. This was the load call:

$( document ).ready( function() {
$( '#searchSubmit' ).click( function() {
q = $( '#q' ).val();
$( '#results' ).html( '' ).load(
'{% url userbase_user_search %}?q=' + q );
});
});

Upon setting everything up and clicking the tag, nothing happens as
usual. I'm going to try the tut posted below with high hopes - and I
am considering trying 'djaxice'

On Apr 13, 3:39 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Friday, 13 April 2012 08:08:19 UTC+1, Eli_West wrote:
>
> > I've been attempting the most basic ajax call (.load()  )  through
> > django for over a month now - each time trying a different method or
> > tutorial none with success. Can someone post a working paradigm for
> > whatever django csrf, firefox, ect. workaround they use?
>
> > I can get jquery .load() to load content from an external file with
> > static files , no django. Same file served through django/templating
> > and the ajax is blocked. This is the general jquery call:
>
> > $(document).ready(function() {
> >     $('.list').click(function () {
> > $('#message').load('namesinfo.htm li');
> >         return false;
> >     });
> > });
>
> > To make things worse I found that Firefox/Chrome breaks Jquery's
> > sample 'Tabs: load content via ajax'  in the Themroller download. But
> > it works in IE :/. Same .load() calls occuring here. Just working w
> > static files no django. Could it be related to Firefox/Chrome?
>
> > I am pretty sure it is not: static file serving issues. I have heard
> > comments to follow django 'csrf / ajax' and included their sameOrgin
> > script to no avail. :
>
> >https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
>
> > A similar issue even though this guys solution is hard to understand:
>
> >http://stackoverflow.com/questions/6643242/jquery-load-not-working-in...
>
> The argument to `load` is the URL you want to load. If you want that to be
> served by Django, you need to pass in a URL that's handled by your Django
> urls.py. 'namesinfo.htm' seems unlikely to be a Django url.
> --
> DR.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Working Hello World Ajax example via django pleeeease

2012-04-13 Thread Eli_West
I've been attempting the most basic ajax call (.load()  )  through
django for over a month now - each time trying a different method or
tutorial none with success. Can someone post a working paradigm for
whatever django csrf, firefox, ect. workaround they use?

I can get jquery .load() to load content from an external file with
static files , no django. Same file served through django/templating
and the ajax is blocked. This is the general jquery call:

$(document).ready(function() {
$('.list').click(function () {
$('#message').load('namesinfo.htm li');
return false;
});
});

To make things worse I found that Firefox/Chrome breaks Jquery's
sample 'Tabs: load content via ajax'  in the Themroller download. But
it works in IE :/. Same .load() calls occuring here. Just working w
static files no django. Could it be related to Firefox/Chrome?

I am pretty sure it is not: static file serving issues. I have heard
comments to follow django 'csrf / ajax' and included their sameOrgin
script to no avail. :

https://docs.djangoproject.com/en/dev/ref/contrib/csrf/

A similar issue even though this guys solution is hard to understand:

http://stackoverflow.com/questions/6643242/jquery-load-not-working-in-django




-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Ajax/jquery .load() unresponsive via django html templating, or FF/chrome

2012-03-20 Thread Eli_West
Thanks, I think I did read the page that recommends adding a script
and did so but no help there. I'll doublecheck but it just seems like
there is not very much info on this topic.

Is it safe to say that somehow having django templating in the middle
is causing xss issues to0? Extra content from .load() is still coming
from localhost so I can't see how it would blocked.

thx

On Mar 20, 4:26 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Mon, Mar 19, 2012 at 6:52 AM, Eli_West <e...@trakdrop.com> wrote:
> > 2 potential issues I've been trying solve:
>
> > 1) Django csrf or other mechanism is blocking ajax and jquery .load()
>
> > […]
>
> Are you following the advice laid out in the Django manual on AJAX And CSRF?
>
> Cheers
>
> Tom

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Ajax/jquery .load() unresponsive via django html templating, or FF/chrome

2012-03-19 Thread Eli_West
2 potential issues I've been trying solve:

1) Django csrf or other mechanism is blocking ajax and jquery .load()

   This following simple ajax interaction works by opening directly in
a browser, but not through a django view:
  ( assume content to load from namesinfo.htm is available)

javascript
$(document).ready(function() {
$('.list').click(function () {
$('#message').load('namesinfo.htm li');
return false;
});
});

//html part ///
We are going to organize the Conference on IT on 2nd Feb 2010
Participants


Inline script or separate file doesn't seem to matter, so seems like
django is blocking this.

2) However more problems arise where Firefox/Chrome won't load ajax at
all !! Not even using django here. So I can't tell if there is a
django issue or FF.
This standard jquery example works for me only in Windows IE,
nothing else:

///js

$(function() {
$( "#tabs" ).tabs({
ajaxOptions: {
error: function( xhr, status, index, anchor ) {
$( anchor.hash ).html(
"Couldn't load this tab. We'll 
try to fix this as soon as
possible. " +
"If this wouldn't be a demo." );
}
}
});
});


html



Preloaded
Tab 1
Tab 2


blah



Any thoughts appreciated.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Jquery .load() function not responding with django

2012-03-15 Thread Eli_West
Found that jquery ajax does not load correctly in my firefox install.
Stock jquery example wasnt working either so I ran it in  a Windows IE
install.



On Mar 14, 8:59 pm, Eli_West <e...@trakdrop.com> wrote:
> I just updated the jquery library so I shouldn't be that.
>
> Ive got to be doing something wrong.. theres no way .load() simply
> doesn't work with django.
>
> On Mar 14, 8:39 pm, Eli_West <e...@trakdrop.com> wrote:
>
>
>
>
>
>
>
> > Thanks for the reply. It is loaded as an external script/file. That is
> > how it listed below right? Ive tried including it right in the file
> > too.
>
> > I think I know what you mean about using the url tag, I justed tried
> > this solution but with no results:
>
> >         $(document).ready(function() {
> >     $('.list').click(function () {
>
> >         $('#message').load('{{ url testload}}');
> >         return false;
> >     });
>
> > });
>
> > which calls a django view to serve the page. Still does not work
> > however, unless I am doing it incorrectly. Could it be a jquery
> > library error. Here is my django view and url now:
>
> > def testload(request):
> >     return render_to_response('tdcreative/testcontent.htm')
>
> > 
> > // in url conf
> >  (r'^tdcreative/testload/$', 'tdcreative.views.testload'),
>
> > On Mar 14, 12:02 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
>
> > > On Wednesday, 14 March 2012 09:21:29 UTC-7, Eli_West wrote:
>
> > > > I've ran into in issue where jquery .load() will load extra content by
> > > > directly opening html file in a browser but if served through Django
> > > > devel server the jquery load() is ignored. Have no idea what could be
> > > > happening but I've seen someone use a django url in the .load() call
> > > > instead of pointing .load() directly to a file:
>
> > > > 
> > > >     $('.myClass').load('{% url update_dropdown %}',
> > > >         {'kind': "Book" },
> > > >         function(data){
> > > >             alert(data);
> > > >      });
>
> > > > 
>
> > > > He said he saw issues with a jquery library Any thoughts would be
> > > > great. BTW not a static file serving issue. Here is the very simple
> > > > code that works w/o django, but same thing loaded through django
> > > > fails:
>
> > > > ///code from apress jquery, thanks to Bintu Harwani
>
> > > > basic jquery load function
>
> > > > $(document).ready(function() {
> > > >     $('.list').click(function () {
> > > > $('#message').load('namesinfo.htm li');
> > > >         return false;
> > > >     });
> > > > });
>
> > > > /basic html file
>
> > > >  > > >         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>
>
> > > > http://www.w3.org/1999/xhtml; xml:lang="en" lang="en">
> > > >   
> > > >         
> > > >         JQuery Examples
> > > >         </
> > > > script>
> > > >         <script src="d6.js" type="text/javascript">
> > > >   
> > > > 
> > > > We are going to organize the Conference on IT on 2nd Feb 2010
> > > > Participants
> > > > 
> > > > 
>
> > > > //names info .htm with extra content to load
> > > > The list of the persons taking part in conference 
> > > > 
> > > > Jackub
> > > > Jenny
> > > > Jill
> > > > John
> > > > 
> > > > We wish them All the Best
>
> > > Where is that script in relation to your base html file? Is it directly
> > > included (if so, you don't show it)? Or is it being loaded as an external
> > > script? If so, you can't put Django template code (eg the {% url %} tag) 
> > > in
> > > it, as it is not parsed as a template.
> > > --
> > > DR.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Jquery .load() function not responding with django

2012-03-14 Thread Eli_West
I just updated the jquery library so I shouldn't be that.

Ive got to be doing something wrong.. theres no way .load() simply
doesn't work with django.



On Mar 14, 8:39 pm, Eli_West <e...@trakdrop.com> wrote:
> Thanks for the reply. It is loaded as an external script/file. That is
> how it listed below right? Ive tried including it right in the file
> too.
>
> I think I know what you mean about using the url tag, I justed tried
> this solution but with no results:
>
>         $(document).ready(function() {
>     $('.list').click(function () {
>
>         $('#message').load('{{ url testload}}');
>         return false;
>     });
>
> });
>
> which calls a django view to serve the page. Still does not work
> however, unless I am doing it incorrectly. Could it be a jquery
> library error. Here is my django view and url now:
>
> def testload(request):
>     return render_to_response('tdcreative/testcontent.htm')
>
> 
> // in url conf
>  (r'^tdcreative/testload/$', 'tdcreative.views.testload'),
>
> On Mar 14, 12:02 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
>
>
>
>
>
>
>
> > On Wednesday, 14 March 2012 09:21:29 UTC-7, Eli_West wrote:
>
> > > I've ran into in issue where jquery .load() will load extra content by
> > > directly opening html file in a browser but if served through Django
> > > devel server the jquery load() is ignored. Have no idea what could be
> > > happening but I've seen someone use a django url in the .load() call
> > > instead of pointing .load() directly to a file:
>
> > > 
> > >     $('.myClass').load('{% url update_dropdown %}',
> > >         {'kind': "Book" },
> > >         function(data){
> > >             alert(data);
> > >      });
>
> > > 
>
> > > He said he saw issues with a jquery library Any thoughts would be
> > > great. BTW not a static file serving issue. Here is the very simple
> > > code that works w/o django, but same thing loaded through django
> > > fails:
>
> > > ///code from apress jquery, thanks to Bintu Harwani
>
> > > basic jquery load function
>
> > > $(document).ready(function() {
> > >     $('.list').click(function () {
> > > $('#message').load('namesinfo.htm li');
> > >         return false;
> > >     });
> > > });
>
> > > /basic html file
>
> > >  > >         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>
>
> > > http://www.w3.org/1999/xhtml; xml:lang="en" lang="en">
> > >   
> > >         
> > >         JQuery Examples
> > >         </
> > > script>
> > >         <script src="d6.js" type="text/javascript">
> > >   
> > > 
> > > We are going to organize the Conference on IT on 2nd Feb 2010
> > > Participants
> > > 
> > > 
>
> > > //names info .htm with extra content to load
> > > The list of the persons taking part in conference 
> > > 
> > > Jackub
> > > Jenny
> > > Jill
> > > John
> > > 
> > > We wish them All the Best
>
> > Where is that script in relation to your base html file? Is it directly
> > included (if so, you don't show it)? Or is it being loaded as an external
> > script? If so, you can't put Django template code (eg the {% url %} tag) in
> > it, as it is not parsed as a template.
> > --
> > DR.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Jquery .load() function not responding with django

2012-03-14 Thread Eli_West

Thanks for the reply. It is loaded as an external script/file. That is
how it listed below right? Ive tried including it right in the file
too.

I think I know what you mean about using the url tag, I justed tried
this solution but with no results:

$(document).ready(function() {
$('.list').click(function () {

$('#message').load('{{ url testload}}');
return false;
});
});


which calls a django view to serve the page. Still does not work
however, unless I am doing it incorrectly. Could it be a jquery
library error. Here is my django view and url now:

def testload(request):
return render_to_response('tdcreative/testcontent.htm')


// in url conf
 (r'^tdcreative/testload/$', 'tdcreative.views.testload'),







On Mar 14, 12:02 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Wednesday, 14 March 2012 09:21:29 UTC-7, Eli_West wrote:
>
> > I've ran into in issue where jquery .load() will load extra content by
> > directly opening html file in a browser but if served through Django
> > devel server the jquery load() is ignored. Have no idea what could be
> > happening but I've seen someone use a django url in the .load() call
> > instead of pointing .load() directly to a file:
>
> > 
> >     $('.myClass').load('{% url update_dropdown %}',
> >         {'kind': "Book" },
> >         function(data){
> >             alert(data);
> >      });
>
> > 
>
> > He said he saw issues with a jquery library Any thoughts would be
> > great. BTW not a static file serving issue. Here is the very simple
> > code that works w/o django, but same thing loaded through django
> > fails:
>
> > ///code from apress jquery, thanks to Bintu Harwani
>
> > basic jquery load function
>
> > $(document).ready(function() {
> >     $('.list').click(function () {
> > $('#message').load('namesinfo.htm li');
> >         return false;
> >     });
> > });
>
> > /basic html file
>
> >  >         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>
>
> > http://www.w3.org/1999/xhtml; xml:lang="en" lang="en">
> >   
> >         
> >         JQuery Examples
> >         </
> > script>
> >         <script src="d6.js" type="text/javascript">
> >   
> > 
> > We are going to organize the Conference on IT on 2nd Feb 2010
> > Participants
> > 
> > 
>
> > //names info .htm with extra content to load
> > The list of the persons taking part in conference 
> > 
> > Jackub
> > Jenny
> > Jill
> > John
> > 
> > We wish them All the Best
>
> Where is that script in relation to your base html file? Is it directly
> included (if so, you don't show it)? Or is it being loaded as an external
> script? If so, you can't put Django template code (eg the {% url %} tag) in
> it, as it is not parsed as a template.
> --
> DR.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Jquery .load() function not responding with django

2012-03-14 Thread Eli_West
I've ran into in issue where jquery .load() will load extra content by
directly opening html file in a browser but if served through Django
devel server the jquery load() is ignored. Have no idea what could be
happening but I've seen someone use a django url in the .load() call
instead of pointing .load() directly to a file:


$('.myClass').load('{% url update_dropdown %}',
{'kind': "Book" },
function(data){
alert(data);
 });



He said he saw issues with a jquery library Any thoughts would be
great. BTW not a static file serving issue. Here is the very simple
code that works w/o django, but same thing loaded through django
fails:


///code from apress jquery, thanks to Bintu Harwani

basic jquery load function

$(document).ready(function() {
$('.list').click(function () {
$('#message').load('namesinfo.htm li');
return false;
});
});


/basic html file

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>

http://www.w3.org/1999/xhtml; xml:lang="en" lang="en">
  

JQuery Examples


  

We are going to organize the Conference on IT on 2nd Feb 2010
Participants



//names info .htm with extra content to load
The list of the persons taking part in conference 

Jackub
Jenny
Jill
John

We wish them All the Best

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Issue with relational /absolute {{url}} call

2012-02-24 Thread Eli_West
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/media/dir/somefile

Pasting in a static extension of:

/site_media/dirxx/filename

Works but is obviously useless in html tag.


 Is there a setting that forces the {{.url }} call to give a full
path
rather than relative?

ANY thoughts would be appreciated. Here are some of my settings:

(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/home/trak/media'}),

MEDIA_ROOT = ''

MEDIA_URL = '/home/trak/media/'

## Django settings



SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = False


# Absolute filesystem path to the directory that will hold user-
uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# Examples: "http://media.lawrence.com/media/;, "http://example.com/
media/"
MEDIA_URL = '/home/trak/media/'

# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# Example: "http://media.lawrence.com/static/;
STATIC_URL = '/static/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/;, "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/
static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'user_profiles.middleware.CurrentUserMiddleware',
)

ROOT_URLCONF = 'trakdrop.urls'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'registration',
'tdcreative',

# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)

'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}


Thanks.

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Site Urls and site_media random config change

2012-02-23 Thread Eli_West
Static media under the development server worked without a problem for
me for a few months, and still does but calling:

{{ modelxx.objectyy.url }}

to get a file url seemed to add full path out of nowhere instead of
relative path. Now

/site_media/{{ modelxx.objectyy.url }}

gives double prefix of : /home/trak/media/home/trak/media/dir/
filename ; my plugin that uses this URL is now broken. Removing the /
site_media/ prefix and using just

fileurl = {{ modelxx.objectyy.url }}

would seem to work and gives the exact path /home/trak/media/dir/
filename, but miraculously does not work. Perhaps calling  /home/
directly perms problem? Anyway the only way I can get the url to work
is by keeping the /site_media/ prefix and pasting in a static
extension:

/site_media/dirxx/filename


I am at a complete loss but know that originally the combination /
site_media/{{ modelxx.objectyy.url }}  worked fine and now the
{{  .url  }} usage seems to have thrown in full path. I was trying
some experiments with external apps and app some includes but I do not
see how this would affect any thing. I did turn off  USE_I18n in
settings file. Here are my 3 url settings, and below is most of my
settings file:
Is there a setting that forces the {{.url }} call to give a full path
rather than relative?

ANY thoughts would be appreciated.


(r'^site_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/home/trak/media'}),

MEDIA_ROOT = ''

MEDIA_URL = '/home/trak/media/'


## Django settings

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS


# system time zone.
TIME_ZONE = 'America/Chicago'


SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = False

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-
uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# Examples: "http://media.lawrence.com/media/;, "http://example.com/
media/"
MEDIA_URL = '/home/trak/media/'

# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# Example: "http://media.lawrence.com/static/;
STATIC_URL = '/static/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/;, "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/
static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)


# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'user_profiles.middleware.CurrentUserMiddleware',
)

ROOT_URLCONF = 'trakdrop.urls'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'registration',
'tdcreative',



# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)


'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



models.FileField versus forms.FileField

2011-11-07 Thread Eli_West
Hello,

When creating a working with the models and views to upload files what
is the difference between models.FileField and forms.FileField? Just a
practical usage explanation would be good at this point.

i can't find any comparison of the two but django directions and
examples use one or the other. I've gotten forms that use
models.FileField calls to work but the forms.FileField seems to act
up. For example this general django directions use the
form.fileField:

from django import forms

class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file  = forms.FileField()

def upload_file(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
handle_uploaded_file(request.FILES['file'])
return HttpResponseRedirect('/success/url/')
else:
form = UploadFileForm()
return render_to_response('upload.html', {'form': form})

def handle_uploaded_file(f):
destination = open('some/file/name.txt', 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()

All the chunks() calls and others seem helpful but the
models.FileField ( upload to = /somedir)   gets things done in a snap.

Any recommendations?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.