How to serve a static file with django?

2015-12-23 Thread Dan Bikle
*Hi List,*























































*I am new to django.I read 
this:https://docs.djangoproject.com/en/1.9/howto/static-files/I did this:cd 
~django-admin startproject mysiteI see this in 
~/mysite/mysite/settings.pyINSTALLED_APPS = ['django.contrib.admin',
'django.contrib.auth','django.contrib.contenttypes',
'django.contrib.sessions','django.contrib.messages',
'django.contrib.staticfiles',]So, I see staticfiles in there.cd 
mysitepython manage.py startapp my_appmkdir -p my_app/static/my_appecho 
hello > my_app/static/my_app/hello.htmlpython manage.py runserverOther 
terminal:curl 127.0.0.1:8000/my_app/static/my_app/hello.htmlgives:Page not 
found (404)So, I'm curious.How to serve a static file with django?I sense 
that This URL is leaving out a step or maybe I read it 
wrong:https://docs.djangoproject.com/en/1.9/howto/static-files/??I am 
running this django:>>> import django>>> print(django.get_version())1.9>>> 
>>> *

-- 
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/6ebacf12-c365-4a0d-bd23-c18926c9fff6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to serve a static file with django?

2015-12-23 Thread Vijay Khemlani
I guess the URL would be something like this

127.0.0.1:8000/static/my_app/hello.html

(without the first "my_app")

assuming your STATIC_URL is '/static/'

On Wed, Dec 23, 2015 at 1:57 AM, Dan Bikle  wrote:

> *Hi List,*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *I am new to django.I read
> this:https://docs.djangoproject.com/en/1.9/howto/static-files/
> I did this:cd
> ~django-admin startproject mysiteI see this in
> ~/mysite/mysite/settings.pyINSTALLED_APPS = ['django.contrib.admin',
> 'django.contrib.auth','django.contrib.contenttypes',
> 'django.contrib.sessions','django.contrib.messages',
> 'django.contrib.staticfiles',]So, I see staticfiles in there.cd
> mysitepython manage.py startapp my_appmkdir -p my_app/static/my_appecho
> hello > my_app/static/my_app/hello.htmlpython manage.py runserverOther
> terminal:curl 127.0.0.1:8000/my_app/static/my_app/hello.html
> gives:Page not found
> (404)So, I'm curious.How to serve a static file with django?I sense that
> This URL is leaving out a step or maybe I read it
> wrong:https://docs.djangoproject.com/en/1.9/howto/static-files/
> ??I am running
> this django:>>> import django>>> print(django.get_version())1.9>>> >>> *
>
> --
> 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/6ebacf12-c365-4a0d-bd23-c18926c9fff6%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/CALn3ei0hoDbs4eWYbj%2B6j5iSxBzgHjFYtXWh2G8QTaPWpPyieA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to serve a static file with django?

2015-12-23 Thread Jani Tiainen

Hi,

Also staticfiles and serving them is gone quire throughly in Django 
official tutorial part 6 
<https://docs.djangoproject.com/en/1.9/intro/tutorial06/>


On 23.12.2015 06:57, Dan Bikle wrote:

*Hi List,*
*
I am new to django.

I read this:
https://docs.djangoproject.com/en/1.9/howto/static-files/

I did this:

cd ~
django-admin startproject mysite

I see this in
~/mysite/mysite/settings.py

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

So, I see staticfiles in there.

cd mysite
python manage.py startapp my_app
mkdir -p my_app/static/my_app
echo hello > my_app/static/my_app/hello.html
python manage.py runserver

Other terminal:

curl 127.0.0.1:8000/my_app/static/my_app/hello.html

gives:

Page not found (404)

So, I'm curious.

How to serve a static file with django?

I sense that
This URL is leaving out a step or maybe I read it wrong:
https://docs.djangoproject.com/en/1.9/howto/static-files/
??

I am running this django:

>>> import django
>>> print(django.get_version())
1.9
>>>
>>>
*
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/6ebacf12-c365-4a0d-bd23-c18926c9fff6%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/6ebacf12-c365-4a0d-bd23-c18926c9fff6%40googlegroups.com?utm_medium=email&utm_source=footer>.

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/567A8E3E.1050702%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to serve a static file with django?

2015-12-24 Thread cquptzzq
This problem has troubled me also.
In the DJANGO PROJECT website, they said " we want you to put static files 
on web server instead of using local directories "
So,why not?
Just drop it on the web server, and then use the http url to load images or 
css.

在 2015年12月23日星期三 UTC+8下午7:50:52,Dan Bikle写道:
>
> *Hi List,*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *I am new to django.I read 
> this:https://docs.djangoproject.com/en/1.9/howto/static-files/ 
> I did this:cd 
> ~django-admin startproject mysiteI see this in 
> ~/mysite/mysite/settings.pyINSTALLED_APPS = ['django.contrib.admin',
> 'django.contrib.auth','django.contrib.contenttypes',
> 'django.contrib.sessions','django.contrib.messages',
> 'django.contrib.staticfiles',]So, I see staticfiles in there.cd 
> mysitepython manage.py startapp my_appmkdir -p my_app/static/my_appecho 
> hello > my_app/static/my_app/hello.htmlpython manage.py runserverOther 
> terminal:curl 127.0.0.1:8000/my_app/static/my_app/hello.html 
> gives:Page not found 
> (404)So, I'm curious.How to serve a static file with django?I sense that 
> This URL is leaving out a step or maybe I read it 
> wrong:https://docs.djangoproject.com/en/1.9/howto/static-files/ 
> ??I am running 
> this django:>>> import django>>> print(django.get_version())1.9>>> >>> *
>

-- 
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/3efdda46-c737-42f3-8d6d-07e6180f5b48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.