Re: IOError at / [Errno 13] Permission denied

2011-11-23 Thread marjenni
Thank you for your help, that sorted that issue!

On Nov 22, 5:18 pm, Tom Evans  wrote:
> On Tue, Nov 22, 2011 at 10:35 AM, marjenni
>
>
>
>
>
>
>
>
>
>  wrote:
> > Hi all,
> >   I have been writing a django app, and testing locally using
> > runserver.
>
> > Now I am in the process of moving this app to an online server, but am
> > having some problems.
>
> > On initialisation the app initialises itself with a .csv file I have
> > created, but with the online version I keep getting:
>
> > IOError at /
>
> > [Errno 13] Permission denied: '/cache/parks_extended_info.csv'
>
> > I have been playing with file permissions and owners, but just can't
> > get it to work.
>
> > This is my first django app, so the solution is probably simple!
>
> > thanks
>
> > Mark
>
> So, the error is pretty clear - you are trying to open
> '/cache/parks_extended_info.csv', and that fails with permission
> denied (errno 13). It's not clear what mode you are opening it with -
> for reading or for writing?
>
> Some wild speculation - are you really intending to open
> '/cache/parks_extended_info.csv' or should that path be prepended with
> your project path?
>
> When you run it in development, your working directory is probably
> '/path/to/project', and so when you open
> 'cache/parks_extended_info.csv', it correctly opens
> '/path/to/project/cache/parks_extended_info.csv'.
>
> When you run it in production, working directory is probably '/', so
> when you open 'cache/parks_extended_info.csv', it tries to open
> '/cache/parks_extended_info.csv', which probably doesn't exist.
>
> On the other hand, if you are really trying to open
> '/cache/parks_extended_info.csv', then you just need to make sure that
> you have appropriate read permissions on the file, and execute
> permissions on any intermediary directories, for the user that your
> code is running as. If you run these commands, it should be clear why
> you are denied:
>
> ls -ld /cache
> ls -l /cache/parks_extended_info.csv
>
> If you intend to write to the file - or open the file in write or
> append mode - you must also have write permission to the directory,
> and to the file if it already exists.
>
> 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.



Re: Django : CSRF and variable handling in a view

2011-11-23 Thread Ivo Brodien

> What about passing a variable set to False ? Should I still pass it
> like so :
> return render(request,'index.html', {'form': form,
> 'has_account':False})
> Or is it useless to pass it ?

Since you hardcode it to be False, yes it useless also to check in the template.

If the variable is missing a "if" in the template will evaluate to False.

If the template is used by other views which could provide has_account =True it 
should be in there, of course!



> 
> 
> On Nov 23, 5:02 am, DrBloodmoney  wrote:
>> On Tue, Nov 22, 2011 at 6:54 PM, Nolhian  wrote:
>>> Hello,
>> 
>>> I've got a subscription form and this view :
>> 
>>> def index(request):
>>>c = RequestContext(request)
>>>if request.user.is_authenticated():
>>>return render_to_response('index.html', {'has_account': 
>>> True})
>>>if request.method == 'POST':
>>>form = SignupForm(request.POST,error_class=DivErrorList)
>>>if form.is_valid():
>>>return HttpResponseRedirect('/thanks/')
>>>else:
>>>form = SignupForm()
>>>return render_to_response('index.html', {'form': form, 'has_account':
>>> False}, c)
>> 
>>> 1) In Index.html I have a form with a {% csrf_token %}. If I don't put
>>> c = RequestContext(request) and add the c into every
>>> render_to_response I've got a csrf error. Is my view above the right
>>> way to handle csrf ?
>> 
>>> 2) I noticed that instead putting
>>> c = RequestContext(request) *at the beginning of my view*
>>> and :
>>> return render_to_response('index.html', {'form': form, 'has_account':
>>> False}, c) *at the end of my view*
>> 
>>>  I could just put this at the end of my view :
>> 
>>> c = RequestContext(request, {'has_account': False,'form': form})
>>> return render_to_response('index.html', c)
>> 
>>> Which one it the best approach ?
>> 
>>> 3) I also noticed that if i don't pass 'has_account': False to my
>>> template, nothing changes, it still evaluate it as false in {% if
>>> has_account %}. Is it best to pass it to the template anyway ?
>> 
>>> Thanks in advance,
>> 
>>> Nolhian
>> 
>>> --
>>> 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 
>>> athttp://groups.google.com/group/django-users?hl=en.
>> 
>> Just use the render [1] shortcut. It'll put the RequestContext in for you.
>> 
>> [1]https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
> 
> -- 
> 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.



'function' object has no attribute 'as_view'

2011-11-23 Thread youpsla
Hello,
the issue here seems to be trivial, maybe I got something in my eyes,
but I can't find the solution.

Here is my code:

urls.py
url(r"magasin/(?P\d+)/evenement/new/$",
EvenementCreateView.as_view(model=Evenement),
name='new_evenement_magasin'),

views.py:
class EvenementCreateView(CreateView):
form_class = EvenementForm
sucess_url = 'user_magasins'

def dispatch(self, *args, **kwargs):
   bla bla bla 

def form_valid(self, form):
   bl bla bla .
   return HttpResponseRedirect(self.get_success_url())


What is funny here is whatever url of the site I call, even one which
doesn't use this view I've the error describe in the subject. The
traceback point on the line of the urls.py.

I'm not python and django proof, but as far I know class blablabla()
define a Class and not a function !!!

Does someone have an idea here ?

Regards

Alain

-- 
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: How-to for static files?

2011-11-23 Thread Ivo Brodien
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: 
>  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  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  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  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.



Re: 'function' object has no attribute 'as_view'

2011-11-23 Thread Ivo Brodien
does this work?

...
(r"magasin/(?P\d+)/evenement/new/$",EvenementCreateView.as_view(model=Evenement,)),
...


I haven’t used Class based Views yet, but everytime they  show up in the docs 
it is always without using the url function and giving a name. So this is just 
a wild guess.

It seems like it is interpreting EvenementCreateView as a view function not as 
a class and does not let you call as_view.

The error happens always because django looks at all the urls you configured in 
order to know which one to use, this is why it always crashes.




On Nov 23, 2011, at 12:03 , youpsla wrote:

> Hello,
> the issue here seems to be trivial, maybe I got something in my eyes,
> but I can't find the solution.
> 
> Here is my code:
> 
> urls.py
> url(r"magasin/(?P\d+)/evenement/new/$",
> EvenementCreateView.as_view(model=Evenement),
> name='new_evenement_magasin'),
> 
> views.py:
> class EvenementCreateView(CreateView):
>form_class = EvenementForm
>sucess_url = 'user_magasins'
> 
>def dispatch(self, *args, **kwargs):
>   bla bla bla 
> 
>def form_valid(self, form):
>   bl bla bla .
>   return HttpResponseRedirect(self.get_success_url())
> 
> 
> What is funny here is whatever url of the site I call, even one which
> doesn't use this view I've the error describe in the subject. The
> traceback point on the line of the urls.py.
> 
> I'm not python and django proof, but as far I know class blablabla()
> define a Class and not a function !!!
> 
> Does someone have an idea here ?
> 
> Regards
> 
> Alain
> 
> -- 
> 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: 'function' object has no attribute 'as_view'

2011-11-23 Thread youpsla
Hi,
thnaks for your answer. It's the same. it doesn't work.

For information I use generic view for other part of the site with:
url(r"magasin/(?P\d+)/supprimer/$", DeleteView.as_view(model=Magasin, 
success_url="/magasins/liste"), name='magasin_supprimer'),

and it works fine.

And has you say, django seems to believe that EvenementCreateView from 
views.py is a function, but the declaration is:
class EvenementCreateView(CreateView):
.

That's what I dont understand.

I use the same schema for other part and it works fine. I've read my code 
caracter after caracter to compare  it looks very very similar 


Still a mystery for me. 

Again, thanks for your answer


Alain

-- 
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/-/0Tg6RPA34W8J.
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: How-to for static files?

2011-11-23 Thread Ivo Brodien
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  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: 
>> > 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  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/6605

Re: How-to for static files?

2011-11-23 Thread Ivo Brodien
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  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  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: 
>>> >> 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  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 

Re: 'function' object has no attribute 'as_view'

2011-11-23 Thread Ivo Brodien
yeah, very strange.

> url(r"magasin/(?P\d+)/evenement/new/$",
> EvenementCreateView.as_view(model=Evenement),
> name='new_evenement_magasin'),

and you are sure the error is caused by the line above? Commenting it out and 
works? Just asking, since you did not provide the whole error description?

-- 
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: Django : CSRF and variable handling in a view

2011-11-23 Thread Nolhian
Okay thanks !

I also pass has_account=True in the view if the user is authenticated.
I noticed that it evaluated it to False if it was missing, I just
wanted to be sure before removing it that it was not considered to be
"the best practice" to pass it anyway :)

On Nov 23, 10:59 am, Ivo Brodien  wrote:
> > What about passing a variable set to False ? Should I still pass it
> > like so :
> > return render(request,'index.html', {'form': form,
> > 'has_account':False})
> > Or is it useless to pass it ?
>
> Since you hardcode it to be False, yes it useless also to check in the 
> template.
>
> If the variable is missing a "if" in the template will evaluate to False.
>
> If the template is used by other views which could provide has_account =True 
> it should be in there, of course!
>
>
>
>
>
>
>
>
>
> > On Nov 23, 5:02 am, DrBloodmoney  wrote:
> >> On Tue, Nov 22, 2011 at 6:54 PM, Nolhian  wrote:
> >>> Hello,
>
> >>> I've got a subscription form and this view :
>
> >>> def index(request):
> >>>        c = RequestContext(request)
> >>>        if request.user.is_authenticated():
> >>>                return render_to_response('index.html', {'has_account': 
> >>> True})
> >>>        if request.method == 'POST':
> >>>                form = SignupForm(request.POST,error_class=DivErrorList)
> >>>                if form.is_valid():
> >>>                        return HttpResponseRedirect('/thanks/')
> >>>        else:
> >>>                form = SignupForm()
> >>>        return render_to_response('index.html', {'form': form, 
> >>> 'has_account':
> >>> False}, c)
>
> >>> 1) In Index.html I have a form with a {% csrf_token %}. If I don't put
> >>> c = RequestContext(request) and add the c into every
> >>> render_to_response I've got a csrf error. Is my view above the right
> >>> way to handle csrf ?
>
> >>> 2) I noticed that instead putting
> >>> c = RequestContext(request) *at the beginning of my view*
> >>> and :
> >>> return render_to_response('index.html', {'form': form, 'has_account':
> >>> False}, c) *at the end of my view*
>
> >>>  I could just put this at the end of my view :
>
> >>> c = RequestContext(request, {'has_account': False,'form': form})
> >>> return render_to_response('index.html', c)
>
> >>> Which one it the best approach ?
>
> >>> 3) I also noticed that if i don't pass 'has_account': False to my
> >>> template, nothing changes, it still evaluate it as false in {% if
> >>> has_account %}. Is it best to pass it to the template anyway ?
>
> >>> Thanks in advance,
>
> >>> Nolhian
>
> >>> --
> >>> 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 
> >>> athttp://groups.google.com/group/django-users?hl=en.
>
> >> Just use the render [1] shortcut. It'll put the RequestContext in for you.
>
> >> [1]https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
>
> > --
> > 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 
> > athttp://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: Django : CSRF and variable handling in a view

2011-11-23 Thread Ivo Brodien
no problem.

> I also pass has_account=True in the view if the user is authenticated.

in this case in your template you can just do:

{% if user.is_authenticated and user.is_active %}

That is the advantage of using RequestContext.

-- 
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: How-to for static files?

2011-11-23 Thread Ivo Brodien
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  
> 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  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  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 fro

Re: 'function' object has no attribute 'as_view'

2011-11-23 Thread youpsla
Hi again,
yes I'm sure the error comes from here. Bellow is the full trace back:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8010/magasin/

Django Version: 1.3.1
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'south',
 'clients',
 'django.contrib.admin',
 'categories',
 'magasins',
 'registration',
 'profiles',
 'evenements',
 'commandes',
 'debug_toolbar']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "C:\Python27\Lib\site-packages\django\core\handlers\base.py" in 
get_response
  89. response = middleware_method(request)
File "C:\Python27\Lib\site-packages\debug_toolbar\middleware.py" in 
process_request
  70. original_urlconf = __import__(getattr(request, 
'urlconf', settings.ROOT_URLCONF), {}, {}, ['*'])
File "C:\dev\Flash\urls.py" in 
  25. (r'magasin/(?P\d+)/evenement/new/$', 
EvenementCreateView.as_view(model=Evenement)),

Exception Type: AttributeError at /magasin/
Exception Value: 'function' object has no attribute 'as_view'


Any ideas are welcome, because this error let me dry !!! h


Regards

Alain

-- 
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/-/Ijq8McV21HQJ.
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: How-to for static files?

2011-11-23 Thread Guillaume Chorn
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:
), 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  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  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  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.



Import error when unit testing with django.test.client on django 1.1.1

2011-11-23 Thread Erlendur Hákonarson
I am trying to set up unit tests on my project
but when I try to import anything from f.e. django.test
then I get this error:
Traceback (most recent call last):
  File 
"C:\eclipse\plugins\org.python.pydev.debug_2.2.2.2011082312\pysrc\pydev_runfiles.py",
 
line 307, in __get_module_from_str
mod = __import__(modname)
  File "C:/TFSSrc_Branch/DER_UnitTesting/bo/tests/testLists\Test.py", line 
8, in 
from django.test.Client import Client
  File "C:\TFSSrc_Branch\DER_UnitTesting\django\test\__init__.py", line 6, 
in 
from django.test.testcases import TestCase
  File "C:\TFSSrc_Branch\DER_UnitTesting\django\test\testcases.py", line 
10, in 
from django.db import transaction
  File "C:\TFSSrc_Branch\DER_UnitTesting\django\db\__init__.py", line 9, in 

if not settings.DATABASE_ENGINE:
  File "C:\TFSSrc_Branch\DER_UnitTesting\django\conf\__init__.py", line 28, 
in __getattr__
self._import_settings()
  File "C:\TFSSrc_Branch\DER_UnitTesting\django\conf\__init__.py", line 59, 
in _import_settings
self._target = Settings(settings_module)
  File "C:\TFSSrc_Branch\DER_UnitTesting\django\conf\__init__.py", line 94, 
in __init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? 
Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'DER.settings' (Is it on sys.path? 
Does it have syntax errors?): No module named DER.settings
ERROR: Module: Test could not be imported (file: 
C:\TFSSrc_Branch\DER_UnitTesting\bo\tests\testLists\Test.py).

Here is my code:
import unittest
#from django.utils import unittest
from django.test.Client import Client

class TestLists(unittest.TestCase):

def setUp(self):
from django.test import Client
self.client =  Client()
self.client.login(username='erlendurh', password='e12345')

def tearDown(self):
pass

def testGetList(self):

self.client.get('/clearing/rep/contracts/from/2011-11-16/to/2011-11-26/')

if __name__ == "__main__":
unittest.main()

I would be very glad if someone could help me with this problem :)

Best regards
Erlendur

-- 
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/-/Uqka7hRGThwJ.
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: How-to for static files?

2011-11-23 Thread Guillaume Chorn
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  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:  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  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  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:
>>>

Re: 'function' object has no attribute 'as_view'

2011-11-23 Thread eprikazc
You might be re-defining EvenementCreateView somewhere else as a
function. To check it, I would suggest you to look up all occurences
of "EvenementCreateView" in your files.

-- 
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: How-to for static files?

2011-11-23 Thread Guillaume Chorn
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  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  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: > 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  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 whic

Re: 'function' object has no attribute 'as_view'

2011-11-23 Thread eprikazc
You might be overriding EvenementCreateView somewhere else. To check
it I would suggest you to look up all occurencies of
EvenementCreateView in your files

Eugene


On Nov 23, 3:47 pm, youpsla  wrote:
> Hi,
> thnaks for your answer. It's the same. it doesn't work.
>
> For information I use generic view for other part of the site with:
> url(r"magasin/(?P\d+)/supprimer/$", DeleteView.as_view(model=Magasin,
> success_url="/magasins/liste"), name='magasin_supprimer'),
>
> and it works fine.
>
> And has you say, django seems to believe that EvenementCreateView from
> views.py is a function, but the declaration is:
> class EvenementCreateView(CreateView):
> .
>
> That's what I dont understand.
>
> I use the same schema for other part and it works fine. I've read my code
> caracter after caracter to compare  it looks very very similar 
>
> Still a mystery for me.
>
> Again, thanks for your answer
>
> Alain

-- 
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: How-to for static files?

2011-11-23 Thread Guillaume Chorn
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  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  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  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: >> href="/Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css"
>>> type="text/css" />), th

Re: How-to for static files?

2011-11-23 Thread Guillaume Chorn
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
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  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  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  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 l

cannot connect to postgresql database

2011-11-23 Thread TANYA
hello, i am new to python but want to learn a framework like django so
i installed it on ubuntu but cannot connect to the postgresql
databasei done know if this is postgresql problem or ubuntu
problem or django? where should i ask for help to connect django to
postgresql?   i follow the tutorial on djangobook.com

-- 
CHEERS, TANYA

-- 
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: How-to for static files?

2011-11-23 Thread Guillaume Chorn
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  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  > 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  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  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.frame

Can't figure a problem with Users not being able to log in.

2011-11-23 Thread Tyrel Souza
Client emailed me this morning saying:

We have had several complaints from members who are having
trouble logging in. This has been going on for three weeks. When they
log in they are either sent to a blank page or redirected to the login
page with no . We have followed up with several of them, and
apparently after waiting several hours or trying the next day they can
get in and see a record of all of their previously failed login
attempts on their messages page.

For this server we have two separate Apache instances running accessed
via nginx. I am new at this and can't really pinpoint the problem. I
do know that if

$ sudo /home/django/bin/httpd restart

The problem goes away for a little while, but this isn't productive
and only delays fixing the problem.

If anyone has any ideas on what to check, or if you are willing to
help and need more information, please let me know.

Off the top of my head the Django version is 1.0.3 and we are using
Pinax.

-- 
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: cannot connect to postgresql database

2011-11-23 Thread Simon Riggs
On Wed, Nov 23, 2011 at 1:42 PM, TANYA  wrote:

> hello, i am new to python but want to learn a framework like django so
> i installed it on ubuntu but cannot connect to the postgresql
> databasei done know if this is postgresql problem or ubuntu
> problem or django? where should i ask for help to connect django to
> postgresql?   i follow the tutorial on djangobook.com

We need to know more before anybody can help you, no matter where the
problem lies.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
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: How-to for static files?

2011-11-23 Thread Ivo Brodien
Great. Glad te be of help.

and yes, the missing RequestContext was what was missing. And insteas of trying 
months for yourself just drop a few lines here on that list in the furure ;-)

happy coding!

On Nov 23, 2011, at 15:13 , Guillaume Chorn wrote:

> 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  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  
>> 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  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  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',
  

Re: Import error when unit testing with django.test.client on django 1.1.1

2011-11-23 Thread xordoquy
Hi

The error is:

> ImportError: Could not import settings 'DER.settings' (Is it on
> sys.path? Does it have syntax errors?): No module named DER.settings
> ERROR: Module: Test could not be imported (file:
> C:TFSSrc_BranchDER_UnitTestingboteststestListsTest.py).

You should google a bit on how to setup django tests with eclipse.
It looks like eclipse tests do not have your project in their paths
thus it doesn't find DER.settings.

Regards,
Xavier.

-- 
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: Can't figure a problem with Users not being able to log in.

2011-11-23 Thread joelryan2k
Are you running multithreaded?  I had similar issues until I
eliminated threads and just used multiple processes.  Pinax was
involved in my problem, too.

On Nov 23, 9:36 am, Tyrel Souza  wrote:
> Client emailed me this morning saying:
>
>         We have had several complaints from members who are having
> trouble logging in. This has been going on for three weeks. When they
> log in they are either sent to a blank page or redirected to the login
> page with no . We have followed up with several of them, and
> apparently after waiting several hours or trying the next day they can
> get in and see a record of all of their previously failed login
> attempts on their messages page.
>
> For this server we have two separate Apache instances running accessed
> via nginx. I am new at this and can't really pinpoint the problem. I
> do know that if
>
> $ sudo /home/django/bin/httpd restart
>
> The problem goes away for a little while, but this isn't productive
> and only delays fixing the problem.
>
> If anyone has any ideas on what to check, or if you are willing to
> help and need more information, please let me know.
>
> Off the top of my head the Django version is 1.0.3 and we are using
> Pinax.

-- 
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: Large Queryset Calculation In Background?

2011-11-23 Thread Nan

Thanks, Tim -- that looks handy too.

Can anyone comment on the database locking question?


On Nov 22, 10:16 pm, Tim Chase  wrote:
> On 11/22/11 17:04, Nikolas Stevenson-Molnar wrote:
>
> > I wouldn't expect it to lock the database (though someone with more
> > database expertise should address that). I /would/ expect it to consume
> > significant CPU. If you're on UNIX, you could address this issue by
> > making your process 'nice'
>
> There's also an "ionice" that should make disk (and possibly
> network) I/O operate in a manner kinder to your machine.  You'd
> launch your cron job with the nice/ionice settings.
>
> -tkc

-- 
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: 'function' object has no attribute 'as_view'

2011-11-23 Thread youpsla
Hello all,
I've verified that I don't override the class.

I've found the reason of the bug. When I delete "@login_required", it works.

My class was in view.py:

@login_required
class EvenementCreateView(.):
.


I apologize for not have copy/paste that in my first post.

I've done the test with another class, it's the same. Then I 
think @login_required works only for function and not for Class.

I don't know what happend internally ... But for now it's ok for me. I'm 
building the POC. But for production purpose, it will be an issue.



Thanks all for your time.

Regards

Alain

-- 
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/-/Fz84rqy-ANwJ.
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.



Django and its MySQL databases

2011-11-23 Thread Daniele Procida
My old database's tables were MyISAM. On my new server, MySQL by default uses 
InnoDB, which I understand is preferable.

However, when I ask Django tp a new table, on a database on the new server 
(which still contains lots of MyISAM tables imported from the old database) it 
creates them with foreign key contraints.

They then don't work. I can't save or do anything with them, without provoking 
errors like:

(1452, 'Cannot add or update a child row: a foreign key constraint fails 
(`pre2_test`.`cmsplugin_imagesetplugin`, CONSTRAINT 
`cmsplugin_ptr_id_refs_id_9346966b4b4d8e9` FOREIGN KEY (`cmsplugin_ptr_id`) 
REFERENCES `cms_cmsplugin` (`id`))')

If I delete the constraints in the database, then everything works again, even 
if I leave the tables as InnoDB.

So how to proceed from here?

If InnoDB is going to be difficult about foreign key relations, as 
 
suggests, then I'd prefer to use MyISAM, which I guess means working out how to 
reconfigure MySQL.

It has been suggested to convert all the tables to InnoDB: 
.

I don't know if that will solve the problem, but even if it does, then 
presumably only some - the new ones - of the tables in the database 
representing FKs on my models will have the database's constraints.

Does it even matter to have tables without those constraints? Django seemed to 
manage quite happily without them so far?

Many thanks for any suggestions,

Daniele


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



displaying images

2011-11-23 Thread marjenni
Hi all,
   Again, I am sure this is a very common problem for beginners, but
all help appreciated.


In a python function I am building a webpage,  and trying to add
images to a table like this:

html += " 
" % imageName

return HttpResponse(html)


Now the table is displayed fine, but images are missing.

The images are present in the directory /home/www/mysite/images/

and in settings.py

MEDIA_URL = '/home/www/mysite/cache/'

any suggestions?

many thanks

Mark





-- 
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: 'function' object has no attribute 'as_view'

2011-11-23 Thread Ivo Brodien

> I've done the test with another class, it's the same. Then I think 
> @login_required works only for function and not for Class.

https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-class-based-views

explains how to use decorators for classes.

-- 
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: displaying images

2011-11-23 Thread Ivo Brodien
Hi,

did you read and do the tutorials? If not do it and you will learn a lot. [1]

In the tutorial you would learn that you would not want to write HTML code 
inside a view (function) but in a HTML template.

You should also read about how to server static media.[2]

[1] https://docs.djangoproject.com/en/1.3/intro/tutorial01/
[2] https://docs.djangoproject.com/en/1.3/howto/static-files/

Good luck

On Nov 23, 2011, at 17:31 , marjenni wrote:

> Hi all,
>   Again, I am sure this is a very common problem for beginners, but
> all help appreciated.
> 
> 
> In a python function I am building a webpage,  and trying to add
> images to a table like this:
> 
> html += " 
> " % imageName
> 
> return HttpResponse(html)
> 
> 
> Now the table is displayed fine, but images are missing.
> 
> The images are present in the directory /home/www/mysite/images/
> 
> and in settings.py
> 
> MEDIA_URL = '/home/www/mysite/cache/'
> 
> any suggestions?
> 
> many thanks
> 
> Mark
> 
> 
> 
> 
> 
> -- 
> 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: displaying images

2011-11-23 Thread Adam Stein
On Wed, 2011-11-23 at 08:31 -0800, marjenni wrote:
> Hi all,
>Again, I am sure this is a very common problem for beginners, but
> all help appreciated.
> 
> 
> In a python function I am building a webpage,  and trying to add
> images to a table like this:
> 
> html += " 
> " % imageName
> 
> return HttpResponse(html)
> 
> 
> Now the table is displayed fine, but images are missing.
> 
> The images are present in the directory /home/www/mysite/images/
> 
> and in settings.py
> 
> MEDIA_URL = '/home/www/mysite/cache/'
> 
> any suggestions?
> 
> many thanks
> 
> Mark

Whenever something isn't displaying (image) or available (JavaScript
function), I always look at the source of the web page to make sure my
paths are what they are suppose to be and that the content I want is at
that path.

Take a look at the source of your rendered page, make sure the image URL
is correct and that there is actually an image there (open the URL in
it's own browser window/tab).  Hopefully that will lead you to the
source of your problem.

-- 
Adam Stein @ HCL America Inc.Email: a...@ppdev.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]

-- 
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: 'function' object has no attribute 'as_view'

2011-11-23 Thread youpsla
Thanks for all.

Agai I apologize for not having post this "etail" in my originl post.

Regards

Alain

-- 
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/-/cvt5qYYGgDsJ.
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: Looking for my replacement (Lead Developer at a Start-up)

2011-11-23 Thread Hussein Ahmed
Hi Kurtis,
Are they giving equity as part of this or is it just a hourly pay?

On Nov 22, 4:41 pm, Kurtis  wrote:
> Hey Guys,
>
> I am the lead developer at fireflie.com. The site is going through a total
> site-rebuild using Django. I'm taking a research position early next month
> and need to find a replacement very quickly.
>
> I can't go into too many details without an Non-Disclosure Agreement. I
> will point out that due to budgeting, this position cannot pay more than
> $20/hour and will require about 30 hours per week. It's not a substantial
> amount of money but they're an excellent team to work for. Once completed,
> this will be a great project to have on your portfolio.
>
> We need someone to start almost immediately so that I can work with my
> replacement. I need to bring my replacement "up to speed" and make sure
> they're capable of handling the work requirements. The company is based out
> of Texas. I live in Ohio. Telecommuting is obviously okay. They are picky
> about language and cultural barriers because communications is extremely
> important.
>
> Basic Requirements:
>
>    - Python
>    - Django
>    - HTML
>    - CSS
>    - Javascript
>    - JQuery
>
> Helpful Extras:
>
>    - Systems Administration (including DNS)
>    - Amazon Web Services
>    - Nginx
>    - uwsgi
>    - MySQL
>    - A Love of Music
>
> Please contact me immediately if you feel you are willing to take on a
> project of this magnitude and can do so within the constraints of their
> budget. They pay well and this might grow into a full time opportunity
> given the start-up succeeds.
>
> Thanks,
> - Kurtis Mullins

-- 
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: Looking for my replacement (Lead Developer at a Start-up)

2011-11-23 Thread Kurtis Mullins
Hello Hussein,

Thanks a lot for messaging me. At this time, I would only expect hourly pay. 
There may be an option of equity in the future but honestly I can't make that 
decision or give you any guarantees on that matter.

We're received several great replies and are in the middle of reviewing 
applicants. Please let me know if your'e still interested.

Thanks,
- Kurtis Mullins

On Nov 23, 2011, at 12:12 PM, Hussein Ahmed wrote:

> Hi Kurtis,
> Are they giving equity as part of this or is it just a hourly pay?
> 
> On Nov 22, 4:41 pm, Kurtis  wrote:
>> Hey Guys,
>> 
>> I am the lead developer at fireflie.com. The site is going through a total
>> site-rebuild using Django. I'm taking a research position early next month
>> and need to find a replacement very quickly.
>> 
>> I can't go into too many details without an Non-Disclosure Agreement. I
>> will point out that due to budgeting, this position cannot pay more than
>> $20/hour and will require about 30 hours per week. It's not a substantial
>> amount of money but they're an excellent team to work for. Once completed,
>> this will be a great project to have on your portfolio.
>> 
>> We need someone to start almost immediately so that I can work with my
>> replacement. I need to bring my replacement "up to speed" and make sure
>> they're capable of handling the work requirements. The company is based out
>> of Texas. I live in Ohio. Telecommuting is obviously okay. They are picky
>> about language and cultural barriers because communications is extremely
>> important.
>> 
>> Basic Requirements:
>> 
>>- Python
>>- Django
>>- HTML
>>- CSS
>>- Javascript
>>- JQuery
>> 
>> Helpful Extras:
>> 
>>- Systems Administration (including DNS)
>>- Amazon Web Services
>>- Nginx
>>- uwsgi
>>- MySQL
>>- A Love of Music
>> 
>> Please contact me immediately if you feel you are willing to take on a
>> project of this magnitude and can do so within the constraints of their
>> budget. They pay well and this might grow into a full time opportunity
>> given the start-up succeeds.
>> 
>> Thanks,
>> - Kurtis Mullins
> 
> -- 
> 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: Looking for my replacement (Lead Developer at a Start-up)

2011-11-23 Thread Kurtis Mullins
I apologize guys, I tried to use Apple Mail to respond to a post and it
accidentally leaked on to here. Please disregard that message. I'm going to
stick to using gmail! I apologize for releasing a first name. I don't
intend on releasing any private information, in case anyone is concerned!

On Wed, Nov 23, 2011 at 1:08 PM, Kurtis Mullins wrote:

> Hello Hussein,
>
> Thanks a lot for messaging me. At this time, I would only expect hourly
> pay. There may be an option of equity in the future but honestly I can't
> make that decision or give you any guarantees on that matter.
>
> We're received several great replies and are in the middle of reviewing
> applicants. Please let me know if your'e still interested.
>
> Thanks,
> - Kurtis Mullins
>
> On Nov 23, 2011, at 12:12 PM, Hussein Ahmed wrote:
>
> > Hi Kurtis,
> > Are they giving equity as part of this or is it just a hourly pay?
> >
> > On Nov 22, 4:41 pm, Kurtis  wrote:
> >> Hey Guys,
> >>
> >> I am the lead developer at fireflie.com. The site is going through a
> total
> >> site-rebuild using Django. I'm taking a research position early next
> month
> >> and need to find a replacement very quickly.
> >>
> >> I can't go into too many details without an Non-Disclosure Agreement. I
> >> will point out that due to budgeting, this position cannot pay more than
> >> $20/hour and will require about 30 hours per week. It's not a
> substantial
> >> amount of money but they're an excellent team to work for. Once
> completed,
> >> this will be a great project to have on your portfolio.
> >>
> >> We need someone to start almost immediately so that I can work with my
> >> replacement. I need to bring my replacement "up to speed" and make sure
> >> they're capable of handling the work requirements. The company is based
> out
> >> of Texas. I live in Ohio. Telecommuting is obviously okay. They are
> picky
> >> about language and cultural barriers because communications is extremely
> >> important.
> >>
> >> Basic Requirements:
> >>
> >>- Python
> >>- Django
> >>- HTML
> >>- CSS
> >>- Javascript
> >>- JQuery
> >>
> >> Helpful Extras:
> >>
> >>- Systems Administration (including DNS)
> >>- Amazon Web Services
> >>- Nginx
> >>- uwsgi
> >>- MySQL
> >>- A Love of Music
> >>
> >> Please contact me immediately if you feel you are willing to take on a
> >> project of this magnitude and can do so within the constraints of their
> >> budget. They pay well and this might grow into a full time opportunity
> >> given the start-up succeeds.
> >>
> >> Thanks,
> >> - Kurtis Mullins
> >
> > --
> > 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: aggregate(Sum('x')) returns None

2011-11-23 Thread M. Can Bayrak
Agree, i think sum must return decimal. Same problem with me.

-- 
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/-/tS-EZk6nTbEJ.
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: Django for a large social networking or photo sharing site?

2011-11-23 Thread badlearner
@Simon: Thanks for the suggestion and reply. I have a question...

I am an absolute beginner in programming, so the code I write (whilst
using Django) may not be very very mature. So, do you think it would
be okay (easy?) to optimize it as time passes by?

This is probably related to Python, but I want to ask anyway - - if
someone's starting to learn Python what would you suggest he learn?
Python 2.x or 3.x? The problem is, not many APIs support Python 3.x,
do they?

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.



Very strange KeyError on 'PORT' in db/backends/mysql/base.py

2011-11-23 Thread Peter Bengtsson
(django version 1.3.1)

To explain my set up would be very hard as it's not just plain Django but 
there's a bunch of other third parties involved but we'll have to try.

I'm getting this traceback when running tests::

Traceback (most recent call last):
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/utils/unittest/case.py",
 
line 339, in run
testMethod()
  File "/Users/peterbe/dev/MOZILLA/PTO/pto/apps/users/tests.py", line 310, 
in test_mozilla_ldap_backend_basic
user, created = back.get_or_create_user('peter', ldap_user)
  File "/Users/peterbe/dev/MOZILLA/PTO/pto/apps/users/auth/backends.py", 
line 146, in get_or_create_user
.filter(email__iexact=ldap_user.attrs.get('mail')[0])):
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/db/models/query.py",
 
line 107, in _result_iter
self._fill_cache()
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/db/models/query.py",
 
line 772, in _fill_cache
self._result_cache.append(self._iter.next())
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/db/models/query.py",
 
line 273, in iterator
for row in compiler.results_iter():
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/db/models/sql/compiler.py",
 
line 680, in results_iter
for rows in self.execute_sql(MULTI):
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/db/models/sql/compiler.py",
 
line 734, in execute_sql
cursor = self.connection.cursor()
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/db/backends/__init__.py",
 
line 252, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
  File 
"/Users/peterbe/dev/MOZILLA/PTO/pto/vendor/src/django/django/db/backends/mysql/base.py",
 
line 318, in _cursor
if settings_dict['PORT']:
KeyError: 'PORT'

So just above line 318 in db/backends/mysql/base.py I put in this::

 if 'PORT' not in settings_dict:  # my debugging
  from pprint import pprint;pprint(settings_dict)  # mydebugging
  if settings_dict['PORT']:
  kwargs['port'] = int(settings_dict['PORT'])

And then when printed out it prints this::

{'ENGINE': 'django.db.backends.mysql',
 'HOST': 'localhost',
 'NAME': 'test_pto',
 'OPTIONS': {'charset': 'utf8',
 'init_command': 'SET storage_engine=InnoDB',
 'use_unicode': True},
 'PASSWORD': XX,
 'TEST_CHARSET': 'utf8',
 'TEST_COLLATION': 'utf8_general_ci',
 'TEST_MIRROR': None,
 'TEST_NAME': None,
 'TIME_ZONE': 'America/Los_Angeles',
 'USER': 'root'}

As you can see it's a copy of settings.DATABASES but with the name having 
an added prefix of "test_". Except now it's missing 'PORT'.

My settings look like this::

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'pto',
'USER': 'root',
'PASSWORD': ,
'HOST': '',
'PORT': '',
'OPTIONS': {
'init_command': 'SET storage_engine=InnoDB',
'charset' : 'utf8',
'use_unicode' : True,
},
'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_general_ci',
},
}

Having a blank 'PORT' key shouldn't be a problem. Removing the key doesn't 
help. However, setting it to '3306' *does* help but that's not getting to 
the root of the problem. 

I know it's a very very hard problem to debug but by mentioning it perhaps 
other people can chip in some experience. It's a long shot. 

A couple of other things:
* It fails on the first and every test
* Debugging self._connection['default'] a bit I find that it has 'PORT' for 
a while (I think whilst setting up fixtures and stuff) and then stops 
having it.
* I'm using github.com/jbalogh/test-utils but that hasn't changed and it 
used to work perfectly fine a couple of days ago.
* Switching test runner to TEST_RUNNER = 
'django.test.simple.DjangoTestSuiteRunner' solves the problem but I didn't 
need to do this before. 
* Colleagues have been unable to reproduce this using very similar stacks 
which could mean it's OS related to threading or something really 
low-level. Sigh...


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



Perhaps more of a general Python question, but..

2011-11-23 Thread Jeff Heard
I have several django apps. all of which are in separate packages and can
be installed seperately.  I would like them all to be sub-packages of a
master package named "ga" So:

ga.datacube
ga.pyramid
ga.sensorcollection

 and so on.  The problem is that when I install them the packages never
seem to show up.  My project structure looks like this:

GA pyramid project:
/home/jeff/ga/ga_pyramid/
ga/
  __init__.py# contains "import pyramid"
  pyramid/
  models.py
  views.py
  tasks.py
  tests.py
  urls.py
  static/
  templates/


GA datacube project:
/home/jeff/ga/ga_datacube/
ga/
  __init__.py# contains "import datacube"
  datacube/
  models.py
  views.py
  tasks.py
  tests.py
  urls.py
  static/
  templates/


My setup py's packages line for datacube is just ['ga.datacube']

but when install the app in settings.py and then do python manage.py shell,
I get this:

"no module named datacube"

I must be doing something wrong in my setup.py or else my package
structure, but I'm really not sure what. Can I install multiple packages
with the same prefix?

-- 
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: Can't figure a problem with Users not being able to log in.

2011-11-23 Thread Tyrel Souza
We bumped up our preform MPM max threads to 50 from 20, seeing if this
is the problem. Our sysop is out for the week.

On Nov 23, 10:43 am, joelryan2k  wrote:
> Are you running multithreaded?  I had similar issues until I
> eliminated threads and just used multiple processes.  Pinax was
> involved in my problem, too.
>
> On Nov 23, 9:36 am, Tyrel Souza  wrote:
>
>
>
>
>
>
>
> > Client emailed me this morning saying:
>
> >         We have had several complaints from members who are having
> > trouble logging in. This has been going on for three weeks. When they
> > log in they are either sent to a blank page or redirected to the login
> > page with no . We have followed up with several of them, and
> > apparently after waiting several hours or trying the next day they can
> > get in and see a record of all of their previously failed login
> > attempts on their messages page.
>
> > For this server we have two separate Apache instances running accessed
> > via nginx. I am new at this and can't really pinpoint the problem. I
> > do know that if
>
> > $ sudo /home/django/bin/httpd restart
>
> > The problem goes away for a little while, but this isn't productive
> > and only delays fixing the problem.
>
> > If anyone has any ideas on what to check, or if you are willing to
> > help and need more information, please let me know.
>
> > Off the top of my head the Django version is 1.0.3 and we are using
> > Pinax.

-- 
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: Very strange KeyError on 'PORT' in db/backends/mysql/base.py

2011-11-23 Thread Ivo Brodien


> * Colleagues have been unable to reproduce this using very similar stacks 
> which could mean it's OS related to threading or something really low-level. 
> Sigh...

maybe I did a wrong search, but I did

grep -r '3306’ . 

inside the django directory and could not find a place where the default port 
is specified.

Shouldn’t it be there or is this specified in e.g. MySQLdb?


-- 
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: Perhaps more of a general Python question, but..

2011-11-23 Thread DrBloodmoney
On Wed, Nov 23, 2011 at 2:01 PM, Jeff Heard  wrote:
> I have several django apps. all of which are in separate packages and can be
> installed seperately.  I would like them all to be sub-packages of a master
> package named "ga" So:
> ga.datacube
> ga.pyramid
> ga.sensorcollection
>  and so on.  The problem is that when I install them the packages never seem
> to show up.  My project structure looks like this:
> GA pyramid project:
> /home/jeff/ga/ga_pyramid/
> ga/
>   __init__.py        # contains "import pyramid"
>   pyramid/
 __init__.py # needs init
>       models.py
>       views.py
>       tasks.py
>       tests.py
>       urls.py
>       static/
>       templates/
>
> GA datacube project:
> /home/jeff/ga/ga_datacube/
> ga/
>   __init__.py        # contains "import datacube"
>   datacube/
 __init__.py # needs init and here
>       models.py
>       views.py
>       tasks.py
>       tests.py
>       urls.py
>       static/
>       templates/

Make sure you add the __init__.py s to magically transform it into a module

-- 
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: Perhaps more of a general Python question, but..

2011-11-23 Thread Jeff Heard
Okay, I did this, but I also have stuff that I'm adding to the
django.contrib namespace, or at least I did.  I created the following:

django/
  __init__.py # empty
  contrib/
 __init__.py # empty

and in my packages line in setup.py I had just ['django'].

Now I seem to have overwritten all of django, because when I type python
manage.py shell I get

"no module named core.management"

-- Jeff

On Wed, Nov 23, 2011 at 2:15 PM, DrBloodmoney wrote:

> On Wed, Nov 23, 2011 at 2:01 PM, Jeff Heard 
> wrote:
> > I have several django apps. all of which are in separate packages and
> can be
> > installed seperately.  I would like them all to be sub-packages of a
> master
> > package named "ga" So:
> > ga.datacube
> > ga.pyramid
> > ga.sensorcollection
> >  and so on.  The problem is that when I install them the packages never
> seem
> > to show up.  My project structure looks like this:
> > GA pyramid project:
> > /home/jeff/ga/ga_pyramid/
> > ga/
> >   __init__.py# contains "import pyramid"
> >   pyramid/
>  __init__.py # needs init
> >   models.py
> >   views.py
> >   tasks.py
> >   tests.py
> >   urls.py
> >   static/
> >   templates/
> >
> > GA datacube project:
> > /home/jeff/ga/ga_datacube/
> > ga/
> >   __init__.py# contains "import datacube"
> >   datacube/
>  __init__.py # needs init and here
> >   models.py
> >   views.py
> >   tasks.py
> >   tests.py
> >   urls.py
> >   static/
> >   templates/
>
> Make sure you add the __init__.py s to magically transform it into a module
>
> --
> 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: Very strange KeyError on 'PORT' in db/backends/mysql/base.py

2011-11-23 Thread Ivo Brodien
just another wild guess:

in django/db/utils.py Line 84:

for setting in ('NAME', 'USER', 'PASSWORD', 'HOST', 'PORT'):
conn.setdefault(setting, ‘’)

It looks like PORT is set to ‘’ instead of 3306 if missing. But still it should 
be in the dict.

really strange, yes.

-- 
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: Django for a large social networking or photo sharing site?

2011-11-23 Thread Mario Gudelj
I'd suggest you to learn 2.x, since django doesn't run on 3. I would just
get into it. Make sure you learn pure basics of programming and Python and
then just start with that first django Polls tutorial and make sure you
understand every line of code as you go along. Finish few tuts, first 7
chapters of the book and you're good to go my friend! Just start coding.

On 24 November 2011 05:34, badlearner  wrote:

> @Simon: Thanks for the suggestion and reply. I have a question...
>
> I am an absolute beginner in programming, so the code I write (whilst
> using Django) may not be very very mature. So, do you think it would
> be okay (easy?) to optimize it as time passes by?
>
> This is probably related to Python, but I want to ask anyway - - if
> someone's starting to learn Python what would you suggest he learn?
> Python 2.x or 3.x? The problem is, not many APIs support Python 3.x,
> do they?
>
> 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.
>
>

-- 
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: Large Queryset Calculation In Background?

2011-11-23 Thread Nikolas Stevenson-Molnar
What database are you using? You should be able to find information in
the documents about the locking behavior for that database. Compare that
with the operations your running and determine whether they would result
in an exclusive lock.

>From your pseudocode, it looks like you're performing a possibly-lengthy
select, followed by lengthy calculations (not involving database
operations), and then a (presumably) quick save. AFAIK, databases never
lock when doing selects, so depending on the nature of your
calculations, you should be fine.

Additionally, if in doubt, I recommend running some tests with the same
database used in your production environment.

_Nik

On 11/23/2011 8:23 AM, Nan wrote:
> Thanks, Tim -- that looks handy too.
>
> Can anyone comment on the database locking question?
>
>
> On Nov 22, 10:16 pm, Tim Chase  wrote:
>> On 11/22/11 17:04, Nikolas Stevenson-Molnar wrote:
>>
>>> I wouldn't expect it to lock the database (though someone with more
>>> database expertise should address that). I /would/ expect it to consume
>>> significant CPU. If you're on UNIX, you could address this issue by
>>> making your process 'nice'
>> There's also an "ionice" that should make disk (and possibly
>> network) I/O operate in a manner kinder to your machine.  You'd
>> launch your cron job with the nice/ionice settings.
>>
>> -tkc

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



django testing: adapt some vars in settings.py if testing

2011-11-23 Thread Gelonida N
Hi,

I just started reading about django testing.

Now I have a small question.

Whe running tests I would like to change a few variables in settings.py,
but keep all the rest identical.

Example:
- I might like ot change the media directory
- I might like to use another db engine


How can I achieve this best.

The idea, that I have, but that feels a little clumsy is:
create a test_settings.py file.

test_settings.py will just impoert everything from settings.py
and then override the values it wants to.


Somehow I would prefer if settings.py could contain a few if statements
of the kind.

if testing:
   dothis
else:
   dothat

and if I could just type
./manage.py test

Is this possible?
How do you handle such setups?

-- 
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: Django : CSRF and variable handling in a view

2011-11-23 Thread Nolhian
Thanks again, Indeed that is nice to know !

Unfortunately I guess I'm still bound to use
request.user.is_authenticated() in my view in this case :

def index(request):
if request.user.is_authenticated():
return render_to_response('index.html',
{'has_account': True})
if request.method == 'POST':
form =
SignupForm(request.POST,error_class=DivErrorList)
if form.is_valid():
return HttpResponseRedirect('/thanks/')
else:
form = SignupForm()
return render(request,'index.html', {'form': form})

If I don't check anywhere in the view if a user is authenticated, he
can still use the form to post data and my goal is that if a user is
authenticated he can't ( in the template if a user is authenticated it
doesn't display the form ).
I'm aware that it kind of defy the DRY principle because I have to
check both in the view and in the template if a user is authenticated
but I haven't found another way :(

In this perspective is it still better at the beginning of my view  to
put :

if request.user.is_authenticated():
return render(request,'index.html')

which will pass the whole requestcontext and check in the template  :
{% if user.is_authenticated and user.is_active %}

or not pass the whole context like so :

if request.user.is_authenticated():
return render_to_response('index.html',
{'has_account': True})

and check in the template {% if has_account %}. I wonder because it
may be useless here to pass the whole requestcontext and it uses the
same amount of code to write both solutions. What do you think ?

Thanks,
Nolhian

On Nov 23, 2:31 pm, Ivo Brodien  wrote:
> no problem.
>
> > I also pass has_account=True in the view if the user is authenticated.
>
> in this case in your template you can just do:
>
> {% if user.is_authenticated and user.is_active %}
>
> That is the advantage of using RequestContext.

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



Hiring: Kickass Python & Web Developer Budapest

2011-11-23 Thread Agnes File
Job Description of the full time position:
Develop business logic middleware for an internet media content
streaming and download system.
This middleware provides API for - mostly - mobile client apps, and
connects to several backends for accessing content, authentication
etc.
Job also involves implementing, and maintaining the frontend for a
javascript heavy, HTML5 based, web-radio system.

Required skills/experience with:
-Python Superstar
-Javascript
-Web Development
-Google App Engine (  deploying, understanding the datastore,
limitations )
-Organized and responsible, being able to work independently or with
little supervision
-Being able to see things from inception to conception (beginning to
end)
-Making architectural decisions
-Taking over someone else's code
-Being able to communicate in english, writing + speaking.

Knowledge about:
.GIT
.Django
.Continuos Integration
.Backup Strategy Skills
.jQuery
.backbone.js

Estimated starting date:
1st of January

Salary: negotiable

Working place: at the office of the company, Hungary, Budapest
6.district

Contact
j...@lab85.com
Send your english CV if you are interested asap! :)

-- 
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: django testing: adapt some vars in settings.py if testing

2011-11-23 Thread Mike Dewhirst

There was a great solution to this posted just yesterday ...

import sys
if 'runserver' in sys.argv:
DEBUG = True
else:
DEBUG = False


... which suggests

if 'test' in sys.argv:
do this



On 24/11/2011 9:53am, Gelonida N wrote:

Hi,

I just started reading about django testing.

Now I have a small question.

Whe running tests I would like to change a few variables in settings.py,
but keep all the rest identical.

Example:
- I might like ot change the media directory
- I might like to use another db engine


How can I achieve this best.

The idea, that I have, but that feels a little clumsy is:
create a test_settings.py file.

test_settings.py will just impoert everything from settings.py
and then override the values it wants to.


Somehow I would prefer if settings.py could contain a few if statements
of the kind.

if testing:
dothis
else:
dothat

and if I could just type
./manage.py test

Is this possible?
How do you handle such setups?



--
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: django testing: adapt some vars in settings.py if testing

2011-11-23 Thread Gelonida N
Hi Mike,

Yes this idea is simple enough.

I just wondered whether there isn't a tiny risk of finding 'test'
as a paramter of one of the option in some esotheric cases.

For what I am doing the solution should be absolutely fine.

With my habit of using ./manage.py I could even change it to
if sys.argv[1] == 'test'



On 11/24/2011 12:23 AM, Mike Dewhirst wrote:
> There was a great solution to this posted just yesterday ...
> 
> import sys
> if 'runserver' in sys.argv:
> DEBUG = True
> else:
> DEBUG = False
> 
> 
> ... which suggests
> 
> if 'test' in sys.argv:
> do this
> 
> 

-- 
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: Django : CSRF and variable handling in a view

2011-11-23 Thread DrBloodmoney
> If I don't check anywhere in the view if a user is authenticated, he
> can still use the form to post data and my goal is that if a user is
> authenticated he can't ( in the template if a user is authenticated it
> doesn't display the form ).
> I'm aware that it kind of defy the DRY principle because I have to
> check both in the view and in the template if a user is authenticated
> but I haven't found another way :(


This seems all sorts of wrong to me. Why couldn't the user just log
out and then post? Seems like an odd workflow, but I don't know your
business-case here.

You could always control what is shown to the user in the template (to
limit their ability to use your form to post to the view) with

{% if not user.is_authenticated %}
SHOW FORM
{% else %}
you're logged in so you can't post
{% endif %}

-- 
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: Django : CSRF and variable handling in a view

2011-11-23 Thread Nolhian
> This seems all sorts of wrong to me. Why couldn't the user just log
> out and then post? Seems like an odd workflow, but I don't know your
> business-case here.

Yes the user can just log out and then post but since this is a sign-
up form it would seem logical to not be able to sign-up if the user is
logged in which means he already has an account.

> You could always control what is shown to the user in the template (to
> limit their ability to use your form to post to the view) with
>
> {% if not user.is_authenticated %}
> SHOW FORM
> {% else %}
> you're logged in so you can't post
> {% endif %}

That's kind of what I'm doing but I still need to check somewhere in
the view if the user is logged in. If I don't the user can open the
sign-up form page, then open another page of the site and log in, then
switch back to the sign-up form page, send the form ( which will be
validated in the view since there's no checking if the user is
authenticated or not there ) and successfully sign-up again WHILE
being logged in. To be able to do that just seems wrong to me.

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



Named URLs Error

2011-11-23 Thread eeyore
This seems like a very simple problem but I can't figure out why it
doesn't work.

What I am trying to do is to link to a particular view via a named
url.


/urls.py
--
urlpatterns = patterns('',
(r'^products/', include('products.urls')),
)

/products/urls.py
--
from django.conf.urls.defaults import patterns, url

urlpatterns = patterns('products.views',
url(r'^$', view="index", name="products_index"),
)

/templates/products/index.html
--
 Products 

Error
--
In template /home/user/app/templates/inc/header.html, error at line 18
   Caught ImportError while rendering: No module named urls

-- 
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: cannot connect to postgresql database

2011-11-23 Thread TANYA
I follow this page http://www.djangobook.com/en/2.0/chapter02/ but
didnt install django in /home/tanya/. I put it in different place
/home/tanya/learndjango/Django-1.3.1 but I start project in
"learndjango". I install Postgresql with apt-get so Postgresql is not
in this same folder. The page says "Put your code in some directory
outside of the document root." so will that be causing problems with
the database?


On Wed, Nov 23, 2011 at 2:51 PM, Simon Riggs  wrote:
> On Wed, Nov 23, 2011 at 1:42 PM, TANYA  wrote:
>
>> hello, i am new to python but want to learn a framework like django so
>> i installed it on ubuntu but cannot connect to the postgresql
>> databasei done know if this is postgresql problem or ubuntu
>> problem or django? where should i ask for help to connect django to
>> postgresql?   i follow the tutorial on djangobook.com
>
> We need to know more before anybody can help you, no matter where the
> problem lies.
>
> --
>  Simon Riggs   http://www.2ndQuadrant.com/
>  PostgreSQL Development, 24x7 Support, Training & Services
>
> --
> 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.
>
>



-- 
CHEERS, TANYA

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