You are not logged in.

Change Language:

Profile for n2turtles

Name n2turtles
Email Address n/a
Posts7
  • Re: session and error 500
    Board » Django » Middleware
    no I still have the page error 500

    edit I'm trying another way not more successful : with authentication

    if in a terminal, I do
    $ python manage.py shell
    Python 2.6.4 (r264:75706, Oct 27 2009, 06:25:13) 
    [GCC 4.4.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> from django.contrib import auth
    >>> user = auth.authenticate(username='user', password='password')

    no problem

    if I do
    # views.py
    ...
    from django.contrib import auth
    ...
    
    def check_pass(request):
        ...
        user = auth.authenticate(username='other', password=password)
        ...


    I've got an error "no such table: auth_user"
    Environment:
    
    Request Method: POST
    Request URL: http://localhost/check_pass/
    Django Version: 1.1.1
    Python Version: 2.6.4
    Installed Applications:
    ['django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.sites']
    Installed Middleware:
    ('django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware')
    
    
    Traceback:
    File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
      92.                 response = callback(request, *callback_args, **callback_kwargs)
    File "/home/mart/programmation/python/django/martfiles/views.py" in check_pass
      66.         user = auth.authenticate(username='other', password='password')
    File "/usr/lib/python2.6/site-packages/django/contrib/auth/__init__.py" in authenticate
      37.             user = backend.authenticate(**credentials)
    File "/usr/lib/python2.6/site-packages/django/contrib/auth/backends.py" in authenticate
      18.             user = User.objects.get(username=username)
    File "/usr/lib/python2.6/site-packages/django/db/models/manager.py" in get
      120.         return self.get_query_set().get(*args, **kwargs)
    File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in get
      300.         num = len(clone)
    File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in __len__
      81.                 self._result_cache = list(self.iterator())
    File "/usr/lib/python2.6/site-packages/django/db/models/query.py" in iterator
      238.         for row in self.query.results_iter():
    File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py" in results_iter
      287.         for rows in self.execute_sql(MULTI):
    File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py" in execute_sql
      2369.         cursor.execute(sql, params)
    File "/usr/lib/python2.6/site-packages/django/db/backends/util.py" in execute
      19.             return self.cursor.execute(sql, params)
    File "/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py" in execute
      193.         return Database.Cursor.execute(self, query, params)
    
    Exception Type: OperationalError at /check_pass/
    Exception Value: no such table: auth_user
    



    edit : answer here

    --- Last Edited by n2turtles at 2010-01-18 13:24:03 ---
  • session and error 500
    Board » Django » Middleware
    Hello,

    I want to use session on my django website I've this view :
    def check_pass(request):
        if request.session.get('logged_in', False):
            return render_to_response('message.html',{'is_connected':True,})
        
        if request.method != 'POST':
            return render_to_response('message.html',{'is_connected':False,'message':"what are you doing ?"})
        
        form = PasswordForm(request.POST)
        if form.is_valid()==False:
            return render_to_response('home.html',{'form':form,})
            
        # check the password
        # if wrong 
            return render_to_response('message.html',{'is_connected':False,'message':"wrong password"})
        # otherwise
        request.session['logged_in'] = True
        return render_to_response('message.html',{'is_connected':True,})


    if it pass all the test, I've got an 500 error for the "request.session['logged_in'] = True" (I tried with "assert False", the error is there)
    in /var/log/httpd/error.log I've this :
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1] Traceback (most recent call last):
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 245, in __call__
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     response = middleware_method(request, response)
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/contrib/sessions/middleware.py", line 36, in process_response
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     request.session.save()
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py", line 52, in save
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     session_key = self.session_key,
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/base.py", line 152, in _get_session_key
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     self._session_key = self._get_new_session_key()
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/base.py", line 144, in _get_new_session_key
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     if not self.exists(session_key):
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/contrib/sessions/backends/db.py", line 25, in exists
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     Session.objects.get(session_key=session_key)
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 120, in get
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     return self.get_query_set().get(*args, **kwargs)
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 300, in get
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     num = len(clone)
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 81, in __len__
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     self._result_cache = list(self.iterator())
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 238, in iterator
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     for row in self.query.results_iter():
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py", line 287, in results_iter
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     for rows in self.execute_sql(MULTI):
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     cursor.execute(sql, params)
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in execute
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     return self.cursor.execute(sql, params)
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]   File "/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193, in execute
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1]     return Database.Cursor.execute(self, query, params)
    [Sat Jan 16 11:41:29 2010] error [client 127.0.0.1] OperationalError: no such table: django_session


    I've also tried to do my own 500 view
    # from urls.py
    handler500 = 'custom_500'
    
    # from views.py
    def custom_500(request):
        return render_to_response('error500.html')

    but I still arrive on the apache's error page

    thanks
  • Re: get the ip of the visitor
    Board » Django » Python Programming
    sorry I haven't been clear
    I've installed django on my computer and give an access to some of my data with it.
    As I don't want that some people abused of it and download everything over and over, I want to be able to monitor what's happening and eventually detect who's abusing.

    but request.META['REMOTE_ADDR'] seems to work (it says 127.0.0.1 but I guess it's normal)
  • get the ip of the visitor
    Board » Django » Python Programming
    Hi,

    How can I find the ip address of the visitor of my site ?
    Do you know any better way to identify the visitor ? (I know that you can use proxy to bypass the detection)

    thank you
  • Re: Self-hosting
    Board » Getting Started » Setup and Configuration
    ok I think the solution with manage.py is enough for what I'm looking for

    I though that I may not need a full http server such as apache

    I'll certainly come back later because it won't work at the first try :)
  • Re: Self-hosting
    Board » Getting Started » Setup and Configuration
    thank you for your answer
    so what should I use instead of the manage.py ?
    with 192.168... I meant that I should configure something in my router like port forwarding ?
    Django run on the 8000 port I think so if I do a prot forwarding of the 8000 port to 192.168.0.100 (my local ip) and someone outside the network go to http://85.201... (my public ip) he will arrive on my website ?

    After to avoid the chang of IP, I read that I've to look at dynamic dns but it's for later (if I can at first do it with the ip it's good :-) )

    --- Last Edited by n2turtles at 2010-01-11 08:47:21 ---
  • Self-hosting
    Board » Getting Started » Setup and Configuration
    Hello,

    I'm doing a simple website with django and I want to host it myself.
    I've found complicated explanation on how to make it work with mod_python or fastCGI but as it's on my computer, I can do what I want.
    Do I have to install apache ? Because I don't really need to do php and stuff like this, just my django website I want to show to my friends without having to pay for an host.

    If I just make it run with "python manage.py runserver", will it work ?
    I should configure something on http://192.168.0.1 I guess. But what ?
    (newbie question : what should write somebody trying to access my site in the browser ? my ip ?)

    I'm not sure if it's in django I should configure it but as I want to be able to use my computer to surf at the same time, I don't want all my bandwidth busy by someone downloading a file or too many people at the same time (for now I'm glad if 2 people are on the website at the same time). How can I say that there is no more than let say 50 Kb/s in upload coming from django ?

    Thank you


Powered by Sphene Community Tools