IT WORKED!!!  Holy cow.  So my main issue was just not using
RequestContext, right?  Either way, thank you SO much.  I have been stuck
at this point for months!  I can now TRULY begin working on my website.
Wow.  Thank you. So. Much.

best,
Guillaume

On Wed, Nov 23, 2011 at 9:53 PM, Ivo Brodien <i...@brodien.de> wrote:

> ok, i think we got it.
>
> def items(request):
>     item_list=Item.objects.all()
>     return render(request, 'myapp/items.html', {'items_list':items_list},
>         content_type="text/css")
>
>
> you are returning html and text/css. Your HTML includes a CSS but that is
> a different story. The Browser will ask for the included CSS file in a
> different request to the server and the server responds with a static file
> from disk without going through any of your views.
>
> so just remove content_type
>
> or put it to text/html which is the default.
>
> Your browser thinks it is a CSS file instead of HTML.
>
> cheers
> Ivo
>
>
> On Nov 23, 2011, at 14:40 , Guillaume Chorn wrote:
>
> Oops, I guess maybe you meant since I've changed the views.py file since I
> last included it?  Here is the newest version:
>
> http://dpaste.com/660808/
>
> thanks,
> Guillaume
>
> On Wed, Nov 23, 2011 at 9:36 PM, Guillaume Chorn <guillaumech...@gmail.com
> > wrote:
>
>> Sorry, I thought I included my views.py earlier, but here it is:
>>
>> http://dpaste.com/660653/
>>
>> It is the
>>
>> (r'^items/$','myapp.views.items')
>>
>> which is not working.  It shows the expected HTML source--basically,
>> exactly what I have in the template file, except {{ STATIC_URL }} has been
>> changed to '/static' and all of the template tags have been replaced by
>> actual values.  So yes, I think that it's just not rendered.  What could
>> cause this?
>>
>> thanks,
>> Guillaume
>>
>>
>> On Wed, Nov 23, 2011 at 8:23 PM, Ivo Brodien <i...@brodien.de> wrote:
>>
>>> show your myapp.views.py file and is it the
>>>
>>> (r'^home/$','myapp.views.homepage'),
>>>
>>>
>>> which is not working?
>>>
>>> Is it showing the html source that you expect just not rendered or
>>> something else?
>>>
>>> It is always a good idea to provide as much details as possible.
>>>
>>> But yeah, we are getting close.
>>>
>>> cheers
>>> Ivo
>>>
>>>
>>>
>>> Gah!  Removed it, but now when I load up the page, it just shows me HTML
>>> source code.  The rest of the views work fine.
>>>
>>> Sorry for all this trouble.  But at least something is happening with
>>> each change you suggest!  I now have more hope than I've had in quite a
>>> while.  I think we're getting close! =)
>>>
>>> thanks,
>>> Guillaume
>>>
>>> On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien <i...@brodien.de> wrote:
>>>
>>>> you did not read the post by Tom Evans, did you? ;)
>>>>
>>>> remove "django.core.context_processors.tz”,
>>>>
>>>> or just put:
>>>>
>>>> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static",
>>>> "django.contrib.messages.context_processors.messages")
>>>>
>>>>
>>>>
>>>> It was a mistake by me. I posted the one from the dev version.
>>>>
>>>> does it work now?
>>>>
>>>>
>>>>
>>>> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
>>>>
>>>> Hi,
>>>>
>>>> Thanks for continuing to follow up on this.  Something is definitely
>>>> happening now.  I went ahead and put this into my views.py:
>>>>
>>>> from django.shortcuts import render
>>>>
>>>> def items(request):
>>>>     item_list=Item.objects.all()
>>>>     return render(request, 'myapp/items.html', {'item_list':item_list},
>>>>         content_type="text/css")
>>>>
>>>> And now when I try to load the page, I get the following error:
>>>>
>>>> ImproperlyConfigured at /diseases/
>>>>
>>>> Module "django.core.context_processors" does not define a "tz" callable
>>>> request processor
>>>>
>>>> Request Method:     GET
>>>> Request URL:     http://127.0.0.1:8000/diseases/
>>>> Django Version:     1.3.1
>>>> Exception Type:     ImproperlyConfigured
>>>> Exception Value:
>>>>
>>>> Module "django.core.context_processors" does not define a "tz" callable
>>>> request processor
>>>>
>>>> Exception Location:
>>>> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
>>>> in get_standard_processors, line 154
>>>> Python Executable:
>>>> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
>>>> Python Version:     2.7.2
>>>> Python Path:
>>>>
>>>> ['/Users/guillaumechorn/Documents/pharmapipe',
>>>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>>>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>>>
>>>>  
>>>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>>>>
>>>>  
>>>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>>>>
>>>>  
>>>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>>>>
>>>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>>>>
>>>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>>>>
>>>>  
>>>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>>>>
>>>>  
>>>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']
>>>>
>>>> Did something happen to my context.py file?  Here it is:
>>>>
>>>>
>>>>
>>>> http://dpaste.com/660778/
>>>>
>>>> Also, as you can see from the error message above, I am currently using 
>>>> Django 1.3.1.
>>>>
>>>> thanks,
>>>> Guillaume
>>>>
>>>>
>>>>
>>>> On Wed, Nov 23, 2011 at 7:10 PM, Ivo Brodien <i...@brodien.de> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> STATIC_URL is not working in your template because the template does
>>>>> not get the RequestContext, which has all the variables in it.
>>>>>
>>>>> use the render shortcut [1] instead of render_to_reponse
>>>>>
>>>>> BTW: It seems you are using the development version. You should change
>>>>> to 1.3.1
>>>>>
>>>>> Does this help?
>>>>>
>>>>> [1]
>>>>> https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
>>>>>
>>>>>
>>>>> On Nov 23, 2011, at 7:33 , Guillaume Chorn wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> The location of my CSS file is
>>>>> /Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css.
>>>>> Sorry, I may have missed you asking for this earlier.
>>>>>
>>>>> Here is my views.py:
>>>>>
>>>>> http://dpaste.com/660653/
>>>>>
>>>>> When I hardcode the disk location of the CSS file in the template
>>>>> (like so: <link rel="stylesheet"
>>>>> href="/Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css"
>>>>> type="text/css" />), the CSS shows up if I open the template file directly
>>>>> using a browser.  But it still doesn't show up when loading up the page on
>>>>> the development server.
>>>>>
>>>>> thanks,
>>>>> Guillaume
>>>>>
>>>>> On Wed, Nov 23, 2011 at 9:57 AM, Ivo Brodien <i...@brodien.de> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> looks fine.
>>>>>>
>>>>>> yes, show your views.py
>>>>>>
>>>>>> and you can also hardcode the STATIC_URL in the template to see if
>>>>>> the path: src=“/static/stylesheet.css” works.
>>>>>>
>>>>>> or simply open http://127.0.0.1:8000/static/stylesheet.css in your
>>>>>> browser.
>>>>>>
>>>>>> Again: Where is that CSS file on your disk?
>>>>>>
>>>>>> On Nov 23, 2011, at 2:46 , Guillaume Chorn wrote:
>>>>>>
>>>>>> Sorry, I think I made something confusing.  In my original file, I
>>>>>> only pasted the URL pattern for the site homepage.  However, this is not
>>>>>> the page I'm trying to style (or link to the CSS file).  The page I'm
>>>>>> trying to link to the CSS file is a separate one, which I have previously
>>>>>> referred to as http://127.0.0.1:8000/view/, but which I will
>>>>>> hereafter refer to as http://127.0.0.1:8000/items/ (and will now
>>>>>> include below).  I previously used the term "view" to imply a general
>>>>>> myapp.views.view, but will hereafter refer to it as myapp.views.items.
>>>>>> Hope that makes sense.  I've used dpaste to share my code as suggested.
>>>>>>
>>>>>> Here is my settings.py file:
>>>>>>
>>>>>> http://dpaste.com/660563/
>>>>>>
>>>>>> Here is the template which I want to style:
>>>>>>
>>>>>> http://dpaste.com/660565/
>>>>>>
>>>>>> And here is my urls.py file:
>>>>>>
>>>>>> http://dpaste.com/660568/
>>>>>>
>>>>>> Let me know if anything else is needed, such as the views.py file or
>>>>>> something.
>>>>>>
>>>>>> thanks,
>>>>>> Guillaume
>>>>>>
>>>>>> On Wed, Nov 23, 2011 at 7:33 AM, Ivo Brodien <i...@brodien.de> wrote:
>>>>>>
>>>>>>> In your original post you had the url like this:
>>>>>>>
>>>>>>> (r'^home/$','myapp.views.homepage'),
>>>>>>>
>>>>>>>
>>>>>>> than your the url starts with view instead of home so there might be
>>>>>>> something wrong.
>>>>>>>
>>>>>>> just paste these files into somthing like dpaste.com
>>>>>>>
>>>>>>> - settings.py
>>>>>>> - myapp.views.homepage
>>>>>>> - urls.py
>>>>>>>
>>>>>>> cheers
>>>>>>>
>>>>>>>
>>>>>>> On Nov 23, 2011, at 0:29 , Guillaume Chorn wrote:
>>>>>>>
>>>>>>> Thank you Ivo.  Your suggestion makes a lot of sense so I tried it
>>>>>>> out.  Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its
>>>>>>> associated tuple into the settings.py file, I tried to restart the
>>>>>>> development server to see if it worked and it didn't.  I checked the 
>>>>>>> page
>>>>>>> source again and it's still looking for /view/stylesheet.css.  Am I 
>>>>>>> missing
>>>>>>> something else?
>>>>>>>
>>>>>>> thanks,
>>>>>>> Guillaume
>>>>>>>
>>>>>>> On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien <i...@brodien.de> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Finally, I have another question.  In my settings.py file, there is 
>>>>>>>> actually no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed 
>>>>>>>> in the documentation
>>>>>>>>
>>>>>>>>
>>>>>>>> yes.
>>>>>>>>
>>>>>>>> put this in there:
>>>>>>>>
>>>>>>>> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static","django.core.context_processors.tz","django.contrib.messages.context_processors.messages")
>>>>>>>>
>>>>>>>>
>>>>>>>> and try again.
>>>>>>>>
>>>>>>>> What happens in your template is that {{ STATIC_URL }} is empty
>>>>>>>> because the context processor 
>>>>>>>> ““django.core.context_processors.static”” did
>>>>>>>> not put the STATIC_URL into the context. so your path to the file 
>>>>>>>> becomes:
>>>>>>>> /view/stylesheet.css instead of /static/stylesheet.css
>>>>>>>>
>>>>>>>> You have to put the CSS file in a directory called static as
>>>>>>>> mentioned before.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>

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

Reply via email to