Re: show an image in django

2013-01-12 Thread jianhui chen
Really thanks your help. Finally, I find the problem is not in django
settings, but in google engine settings.
By trying many methods, my problem problem is solved by this way.
add
- url: /static
  static_dir: static  #my static folder is in the root of the project
  expiration: '0'
to app.yaml.

and I run command :

./manage.py collectstatic

before I update file to google app engine, but I don't whether this
command is necessary for the static issue.




On Thu, Jan 10, 2013 at 5:39 PM, @jeffblack360 wrote:

> I think your configuration should allow you to hit your image from your
> browser via the following link:
>
> http://localhost:8000/static/images/gauge_example.jpg
>
> If that works change your replace {{STATIC_URL}} with '/static/'...
>
>  = "390" height = "225" />
>
>
> On Tuesday, January 8, 2013 8:41:55 AM UTC-6, jianhui chen wrote:
>>
>> Hi all,
>> I want to show an image in project in which the folder DIR looks like
>> this:
>> images/a.jpg
>> templates/introduction.html
>>
>> In introduction.html I use
>> 
>>
>> It can show image correctly when I open the "introduction.html" directly
>> using firefox, but it shows ""GET /images/gauge_example.jpg HTTP/1.1" 404 "
>> when I open it in 
>> http://127.0.0.1:8000/**introduction/,
>> and there is no image in the webpage.
>>
>> I used the last method in http://stackoverflow.com/**
>> questions/2148738/cannot-get-**images-to-display-in-simple-**django-site.
>>  But it doesn't work.
>>
>> Could anyone give me some suggestions?
>>
>> jianhui
>>
>>
>>
>>
>>
>>  --
> 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/-/AO-VKasUjWcJ.
>
> 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: show an image in django

2013-01-10 Thread @jeffblack360
I think your configuration should allow you to hit your image from your 
browser via the following link:

http://localhost:8000/static/images/gauge_example.jpg

If that works change your replace {{STATIC_URL}} with '/static/'...



On Tuesday, January 8, 2013 8:41:55 AM UTC-6, jianhui chen wrote:
>
> Hi all,
> I want to show an image in project in which the folder DIR looks like this:
> images/a.jpg
> templates/introduction.html
>
> In introduction.html I use
> 
>
> It can show image correctly when I open the "introduction.html" directly 
> using firefox, but it shows ""GET /images/gauge_example.jpg HTTP/1.1" 404 " 
> when I open it in http://127.0.0.1:8000/introduction/, and there is no 
> image in the webpage.
>
> I used the last method in 
> http://stackoverflow.com/questions/2148738/cannot-get-images-to-display-in-simple-django-site.
>  But it doesn't work.
>
> Could anyone give me some suggestions?
>
> jianhui
>
>
>
>
>
>

-- 
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/-/AO-VKasUjWcJ.
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: show an image in django

2013-01-10 Thread Mario Gudelj
Have you tried removing {{ STATIC_URL }} and replacing it with a slash (/)?
Or try appending the slash to the end of
"E:/code/python/djangoBook/django-testapp-develop/static"
in STATICFILES_DIRS.

You can also add DJANGO_ROOT = dirname(dirname(abspath(__file__))) to the
top of your settings.py and then add this below it:


STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
normpath(join(DJANGO_ROOT, 'static')),
)


That works for me in every project, although I don't use Windows, so it may
be different in your case.

-- 
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: show an image in django

2013-01-09 Thread jianhui chen
My setting.py is:
# Initialize App Engine and import the default settings (DB backend, etc.).
# If you want to use a different backend you have to remove all occurences
# of "djangoappengine" from this file.
from djangoappengine.settings_base import *

import os

# Activate django-dbindexer for the default database
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
AUTOLOAD_SITECONF = 'indexes'

SECRET_KEY = '=r-$b*8hglm+858&9t043hlm6-&6-3d3vfc4((7yd0dbrakhvi'

INSTALLED_APPS = (
#'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.staticfiles',
'djangotoolbox',
'autoload',
'dbindexer',
'shape_practice',

# djangoappengine should come last, so it can override a few manage.py
commands
'djangoappengine',

)

MIDDLEWARE_CLASSES = (
# This loads the index definitions, so it has to come first
'autoload.middleware.AutoloadMiddleware',

'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.static',
)

# This test runner captures stdout and associates tracebacks with their
# corresponding output. Helps a lot with print-debugging.
TEST_RUNNER = 'djangotoolbox.test.CapturingTestSuiteRunner'

ADMIN_MEDIA_PREFIX = '/media/admin/'
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)

ROOT_URLCONF = 'urls'
STATIC_URL = '/static/'

# 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.
"E:/code/python/djangoBook/django-testapp-develop/static",  #this only
used for local debug
)

and I use STATIC_URL in the html

But, it must be something wrong in my setting.py since the project can't
find the image.
Any suggestions? Thanks.



On Tue, Jan 8, 2013 at 4:00 PM, Mario Gudelj  wrote:

> Try removing .. from the path. Also make sure your static path is set
> correctly in settings.py
> On 9 Jan, 2013 1:42 AM, "jianhui chen"  wrote:
>
>> Hi all,
>> I want to show an image in project in which the folder DIR looks like
>> this:
>> images/a.jpg
>> templates/introduction.html
>>
>> In introduction.html I use
>> 
>>
>> It can show image correctly when I open the "introduction.html" directly
>> using firefox, but it shows ""GET /images/gauge_example.jpg HTTP/1.1" 404 "
>> when I open it in http://127.0.0.1:8000/introduction/, and there is no
>> image in the webpage.
>>
>> I used the last method in
>> http://stackoverflow.com/questions/2148738/cannot-get-images-to-display-in-simple-django-site.
>>  But it doesn't work.
>>
>> Could anyone give me some suggestions?
>>
>> jianhui
>>
>>
>>
>>
>>
>>  --
>> 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.
>>
>  --
> 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.
>

-- 
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: show an image in django

2013-01-08 Thread Mario Gudelj
Try removing .. from the path. Also make sure your static path is set
correctly in settings.py
On 9 Jan, 2013 1:42 AM, "jianhui chen"  wrote:

> Hi all,
> I want to show an image in project in which the folder DIR looks like this:
> images/a.jpg
> templates/introduction.html
>
> In introduction.html I use
> 
>
> It can show image correctly when I open the "introduction.html" directly
> using firefox, but it shows ""GET /images/gauge_example.jpg HTTP/1.1" 404 "
> when I open it in http://127.0.0.1:8000/introduction/, and there is no
> image in the webpage.
>
> I used the last method in
> http://stackoverflow.com/questions/2148738/cannot-get-images-to-display-in-simple-django-site.
>  But it doesn't work.
>
> Could anyone give me some suggestions?
>
> jianhui
>
>
>
>
>
>  --
> 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.
>

-- 
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.



show an image in django

2013-01-08 Thread jianhui chen
Hi all,
I want to show an image in project in which the folder DIR looks like this:
images/a.jpg
templates/introduction.html

In introduction.html I use


It can show image correctly when I open the "introduction.html" directly
using firefox, but it shows ""GET /images/gauge_example.jpg HTTP/1.1" 404 "
when I open it in http://127.0.0.1:8000/introduction/, and there is no
image in the webpage.

I used the last method in
http://stackoverflow.com/questions/2148738/cannot-get-images-to-display-in-simple-django-site.
But it doesn't work.

Could anyone give me some suggestions?

jianhui

-- 
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.