These are chat archives for django/django

18th
Jun 2018
Curtis Maloney
@funkybob
Jun 18 2018 00:08
that's python2 syntax.... so I'm guessing you're using python3 ?
what version of Python are you using??
what version of Django, too, for that matter...
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:09
python2
hey bro
im trying to execute this project
django 1.2.1
im following this project in github
Curtis Maloney
@funkybob
Jun 18 2018 00:10
1.2???? oh wow
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:10
can you help me to execute it plz !
can u try in ur machine ?
Curtis Maloney
@funkybob
Jun 18 2018 00:11
no.
are y ou sure you're using python2 ? I'm quite sure that line is not an error in 2... only 3
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:21
ok
what i must do ?
i used python3 but the same error
Curtis Maloney
@funkybob
Jun 18 2018 00:25
well, considering that support for python 2.3 was dropped in Django 1.2.1... it may simply be that python 2.7 wasn't out and supported yet...
you might have to drop back to python2.6
however, I just tested, and that syntax is acceptable in 2.7
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:26
oh shit
using python 3
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 18:21:58)
Curtis Maloney
@funkybob
Jun 18 2018 00:26
yeah... Django wasn't py3 compatible until 1.4 or 1.5...
iirc
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:27
yay
wait
i will try to install py2
Curtis Maloney
@funkybob
Jun 18 2018 00:28
I'd be rather concerned about an e-voting solution that's built on such out of date [and unsupported] versions
so once you get it running, I recommend you work to update it
[if nothing else, it'll make a good learning exercise :) ]
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:29
ok
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:43
Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management
@funkybob
$ python2 manager.py
Curtis Maloney
@funkybob
Jun 18 2018 00:53
that's because you installed Django into the python3 env...
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:54
:/
so?
Curtis Maloney
@funkybob
Jun 18 2018 00:54
so Python2 can't find it
how did you install django in the first place, exactly?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:55
pip install Django
in machine
no virtualenv
in first time
now i create virtualenv and im on it
Curtis Maloney
@funkybob
Jun 18 2018 00:56
tip for the future: always use a virtualenv :)
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 00:56
okeeey
i installed Django in this virtualenv
python2.7
Python 2.7.12
Django installed
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:12
why that shit ?
image.png
Curtis Maloney
@funkybob
Jun 18 2018 01:13
did you write a main.html ?
or is there one provided by any of the INSTALLED_APPS ?
ok, there is one provided by the projectc
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:14
there is main.html in templates folder
Curtis Maloney
@funkybob
Jun 18 2018 01:14
but you need to fix their stupid settings.py
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:14
{% extends "base.html" %}

{% block title %}Welcome{% endblock %}

{% block content %}
      <h2>Welcome to GPGVote!</h2>
      <p>
        <b>GPGVote</b> is a <b><i>Web-based electronic voting system</i></b> that implements its security requirements with the use 
        of <b><i>PGP keys</i></b>.
      </p>
      <p>
        GPGVote is considered an academic project, originally designed and implemented by 
        <a href="mailto:ernest0x@dtps.unipi.gr">Petros Moisiadis</a> as his graduate thesis in Information Technology.
      <p>
      {% if logged_in %}
      <div id="main_functions">
        <table cellspacing="40" cellpadding="25" align="center">
          <tr>
            <td><a href="./mypolls/"><img src="/site_media/images/mypolls.png" /></a><br /><b>My Polls</b></td>
            <td><a href="./createpoll/"><img src="/site_media/images/create_poll.png" /></a><br /><b>Create Poll</b></td>
          </tr>
        </table>
      </div>
      {% endif %}
{% endblock %}
Curtis Maloney
@funkybob
Jun 18 2018 01:14
yes, no need to paste it here
the problem is django can't find it...
because where it's been told to look... is wrong....
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:15
ok
soltuion?
solution?
DEBUG=False
???
Curtis Maloney
@funkybob
Jun 18 2018 01:15
I recommend you:
import os
HERE = os.path.dirname(os.path.abspath(__file__))

TEMPLATE_DIRS = [ os.path.join(HERE, 'templates'), ]
did you ever consider you might actually need to, like, know something about django to do this?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:16
where this one ?
Curtis Maloney
@funkybob
Jun 18 2018 01:16
put that in your settings.py to replace the TEMPLATE_DIRS that is there... you know... the one I linked to
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:17
oh shit
i forgot to edit files
i have to edit directory of file
path of templates
yay
i have to edit some lines in settings.py
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:36
hey bro
look:

ViewDoesNotExist at /login/

Could not import gpgvote.gpgauth.views. Error was: No module named fields

@funkybob
Could not import gpgvote.gpgauth.views. Error was: No module named fields
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:47
Traceback
:smile:
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/login/
Django Version: 1.2.1
Python Version: 2.7.12
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'gpgvote.gpgauth',
 'gpgvote.polls',
 'captcha']
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',
 'django.middleware.transaction.TransactionMiddleware')


Traceback:
File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  91.                         request.path_info)
File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
  216.                     sub_match = pattern.resolve(new_path)
File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
  123.             return self.callback, args, kwargs
File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _get_callback
  132.             raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))

Exception Type: ViewDoesNotExist at /login/
Exception Value: Could not import gpgvote.gpgauth.views. Error was: No module named fields
Curtis Maloney
@funkybob
Jun 18 2018 01:48
this could be related to the problem in project layout that was fixed in django 1.4 ...
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:48
hmm ...
Curtis Maloney
@funkybob
Jun 18 2018 01:48
but for now, run a python shell, and try to import gpgvote.gpgauth.views
see where it actually raises the error
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:49
how ?
how i can import it ?
gpgvote.gpgauth.views
Curtis Maloney
@funkybob
Jun 18 2018 01:51
run pytrhon
type "import gpgvote.gpgauth.views" and hit enter [without the quotes, of course]
python... blah... I can't type this morning :)
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:52
import gpgvote.gpgauth.views
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gpgvote.gpgauth.views
Curtis Maloney
@funkybob
Jun 18 2018 01:52
ok... which dir were you in when you ran that? I'm guessing you were in the gpgvote project dir?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:52
yes
Curtis Maloney
@funkybob
Jun 18 2018 01:53
ok... I have an old blog post that might help explain what's going on :: http://musings.tinbrain.net/blog/2012/mar/15/django-vs-pythonpath/
but for now... cd up one level, and try again [that is, to the dir that gpgvote project dir is in]
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:54
oh
look
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpgvote.gpgauth.views
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gpgvote/gpgauth/views.py", line 1, in <module>
    from django.shortcuts import render_to_response, redirect
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 10, in <module>
    from django.db.models.manager import Manager
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/db/__init__.py", line 14, in <module>
    if not settings.DATABASES:
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
    self._setup()
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/conf/__init__.py", line 38, in _setup
    raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
Curtis Maloney
@funkybob
Jun 18 2018 01:55
in that case, go back into gpgvote ... run "python manage.py shell" ... and import again
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 01:55
ok
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/abdelkader/Desktop/GGVote/gpgvote/../gpgvote/gpgauth/views.py", line 9, in <module>
    from gpgvote.gpgauth.forms import RegisterForm, RenewForm, LoginForm
  File "/home/abdelkader/Desktop/GGVote/gpgvote/../gpgvote/gpgauth/forms.py", line 2, in <module>
    from captcha.fields import CaptchaField
ImportError: No module named fields
>>> import gpgauth.views
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/abdelkader/Desktop/GGVote/gpgvote/gpgauth/views.py", line 9, in <module>
    from gpgvote.gpgauth.forms import RegisterForm, RenewForm, LoginForm
  File "/home/abdelkader/Desktop/GGVote/gpgvote/../gpgvote/gpgauth/forms.py", line 2, in <module>
    from captcha.fields import CaptchaField
ImportError: No module named fields
>>>
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 02:06
i got another error
after i tried to run $
Curtis Maloney
@funkybob
Jun 18 2018 02:06
looks like you need to find the 3rd party tool that provides "captcha"
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 02:06
$ python manage.py runserver
look
Validating models...
Unhandled exception in thread started by <function inner_run at 0x7f17595976e0>
Traceback (most recent call last):
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
    self.validate(display_num_errors=True)
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/management/base.py", line 245, in validate
    num_errors = get_validation_errors(s, app)
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/management/validation.py", line 28, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
    self._populate()
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/db/models/loading.py", line 64, in _populate
    self.load_app(app_name)
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in load_app
    models = import_module('.models', app_name)
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/captcha/models.py", line 3, in <module>
    from django.utils import timezone
ImportError: cannot import name timezone
Curtis Maloney
@funkybob
Jun 18 2018 02:07
you need an older version of captcha
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 02:07
:package:
how?
Curtis Maloney
@funkybob
Jun 18 2018 02:08
well, I'd start by hitting up the gpgvote people to include a requirements.txt to tell you whatr versions
but you'll have to look at the release history of the captcha lib to see which django version it supports
I don't recall which version django.utils.timezone was added... possibly 1.4
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 02:09
ok
Curtis Maloney
@funkybob
Jun 18 2018 02:09
afk -- lunch time.
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 02:09
but the creater of this project
wrote that we have to use django 1.2.1
or 1.2.3
not 1.4
plz plz
help!
and enjoy
:package:
yeah i fixed it
look that shit
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 02:14
image.png
image.png
Curtis Maloney
@funkybob
Jun 18 2018 03:11
back
so the first error means your app can't connect to the DB server
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:12
ok connected it
i created postgresql db
created user
and db
image.png
idk
how to deal with that
Curtis Maloney
@funkybob
Jun 18 2018 03:14
did you run "./manage.py syncdb"?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:14
no
Curtis Maloney
@funkybob
Jun 18 2018 03:14
well, do that... tells django to make all the DB tables to back its models
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:14
Yay ...
worked!
thanks bro ^^
lemme check other pages
image.png
css is not working!
no decoration :/
this is a probblem
Curtis Maloney
@funkybob
Jun 18 2018 03:16
static assets...
did you set DEBUG=False at some point?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:16
in settings.py ?
Curtis Maloney
@funkybob
Jun 18 2018 03:16
and are you still using runserver?
yes, in settings.py
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:16
yes
Curtis Maloney
@funkybob
Jun 18 2018 03:17
set it to True
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:17
ok
Curtis Maloney
@funkybob
Jun 18 2018 03:17
then runserver will serve your assets
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:18
did not changed yet
Curtis Maloney
@funkybob
Jun 18 2018 03:18
did you stop and restart runserver?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:18
yes
Curtis Maloney
@funkybob
Jun 18 2018 03:19
I can't remember, then.... 1.2 is so far out of date
consider, 1.3 was released March 23, 2011
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:22
but i have to execute this project
and it's working with 1.2
he executed it with css
and worked as well
Curtis Maloney
@funkybob
Jun 18 2018 03:22
yes
and it will
once you understand how django's static asset handling works... and configure it properly
[btw -- the final 1.2 release was September 10, 2011]
if someone actually is maintaining it, and they care at all about security, they should upgrade its Django version immediately
however, this project hasn't been touched since 2013...
in settings.py set MEDIA_URL to '/media/' ...
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:26
i did
Curtis Maloney
@funkybob
Jun 18 2018 03:26
and MEDIA_ROOT ?
wow... I guess it was 1.3 they introduced staticfiles app
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:31
ok
i need solution
i put media directory
in all MEDIA_*
Curtis Maloney
@funkybob
Jun 18 2018 03:34
ok, so... way back when, in the pre-1.3 days... you'd normally have to set up an alias in your web server for ADMIN_MEDIA_ROOT to point to the admin app's media
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:35
:/
Curtis Maloney
@funkybob
Jun 18 2018 03:36
Django has moved on a long way in these last 7 to 8 years...
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:38
hmm ok
Curtis Maloney
@funkybob
Jun 18 2018 03:39
I'd say try to port it to modern django.... but that's a big ask for someone who doesn't (a) know the app, or (b) know django
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:40
0Yay ///i did it '
Yay i did it ^^
YO YO
image.png
thank you so much bro for you help ^^
Curtis Maloney
@funkybob
Jun 18 2018 03:41
ah, ok, cool
yes... reading docs is a good idea :)
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 03:42
yeah
image.png
look
the goal of creating an app like this is not the app
but the crypto side
look
we have to register with a public key
i will use RSA as a cryptography algorithm
to secure user's votes
:)
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:03

TypeError at /register/

init() got an unexpected keyword argument 'gpgbinary'

i have to upload public key generated by gpgbinary maybe :/
Curtis Maloney
@funkybob
Jun 18 2018 04:08
hard to say without seeing the traceback
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:13
Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/register/
Django Version: 1.2.1
Python Version: 2.7.12
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'gpgvote.gpgauth',
 'gpgvote.polls',
 'captcha']
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',
 'django.middleware.transaction.TransactionMiddleware')


Traceback:
File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "/home/abdelkader/Desktop/GGVote/gpgvote/../gpgvote/gpgauth/views.py" in register
  94.       gpg = GPG(gpgbinary=settings.GNUPGBINARY, gnupghome=settings.GNUPGHOME)

Exception Type: TypeError at /register/
Exception Value: __init__() got an unexpected keyword argument 'gpgbinary'
Curtis Maloney
@funkybob
Jun 18 2018 04:20
so where is GPG imported from? [this smells of another version incompatibility...]
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:21
in settings.py ?
image.png
Curtis Maloney
@funkybob
Jun 18 2018 04:27
no.
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:27
?
Curtis Maloney
@funkybob
Jun 18 2018 04:27
in that code ... gpgvote/gpgauth/views.py ... it's creating an instance of the GPG class
where in that module does it import "GPG"
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:28
ok
Curtis Maloney
@funkybob
Jun 18 2018 04:30
from gnupg import GPG
so time for you to go look at the gnupg module and see how it's supposed to be called
and how it's changed over time
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:31
o
ok
Curtis Maloney
@funkybob
Jun 18 2018 04:31
clearly Django isn't the only lib to have progressed over time :)
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:31
\but how to generate public key for registration ?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:36
idk how to do it
django-gpgauth
who is doing that
:/
Curtis Maloney
@funkybob
Jun 18 2018 04:44
is it from that? or from another package that requires?
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:45
look here what he says: https://github.com/Ernest0x/gpgvote
Curtis Maloney
@funkybob
Jun 18 2018 04:45
no, looks like it is that
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:45
oh sorry
here:
plz
if u understand how it works
tell me how to register ?
Curtis Maloney
@funkybob
Jun 18 2018 04:46
I've never seen these tools before...
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:46
and how to generate public key to register with it
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 04:52
TypeError: init() got an unexpected keyword argument 'gnupghome'
\
:/
problem is here: gpg = gnupg.GPG(gnupghome=homedir)gpg = gnupg.GPG(gnupghome=homedir)
gpg = gnupg.GPG(gnupghome=homedir)
gnupghome
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 05:13
what happened ?
image.png
Traceback (most recent call last):

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 280, in run
    self.result = application(self.environ, self.start_response)

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 142, in get_response
    return self.handle_uncaught_exception(request, resolver, exc_info)

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 181, in handle_uncaught_exception
    return callback(request, **param_dict)

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/views/defaults.py", line 23, in server_error
    t = loader.get_template(template_name) # You need to create a 500.html template.

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/template/loader.py", line 157, in get_template
    template, origin = find_template(template_name)

  File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template
    raise TemplateDoesNotExist(name)

TemplateDoesNotExist: 500.html
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 05:35
i passed this problem
another error:
Traceback:
File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "/home/abdelkader/Desktop/GGVote/gpgvote/../gpgvote/gpgauth/views.py" in register
  94.       gpg = GPG(gpgbinary=settings.GNUPGBINARY, gnupghome=settings.GNUPGHOME)
File "/home/abdelkader/Desktop/GGVote/gpgvote/ggvote/local/lib/python2.7/site-packages/gnupg.py" in __init__
  813.             raise OSError(msg)

Exception Type: OSError at /register/
Exception Value: Unable to run gpg (/usr/lib/gnupg2) - it may not be available.
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 06:00
i have to find path of gnugp to run gpg
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 06:33
wtf
same problem: import gpgvote.gpgauth.views
:/
which we met
:(
Curtis Maloney
@funkybob
Jun 18 2018 06:53
well, you're just going to have to debug it... learn how the lib should be used, and fix the code
Abdelkader Belcaid
@p4p1lio_twitter
Jun 18 2018 06:59
:/
in views.py ?
garynobles
@garynobles
Jun 18 2018 12:19

I'm still trying to get this filter and paging to work, the paging now works, but I can't understand the filtering. I have the filtering working in a filter only (no pagination)

def containerpage(request):
    filtered_qs = filters.ContainerFilter(request.GET,queryset=Container.objects.all()).qs
    paginator = Paginator(filtered_qs, 10)

    page = request.GET.get('page')
    try:
        response = paginator.page(page)
    except PageNotAnInteger:
        response = paginator.page(1)
    except EmptyPage:
        response = paginator.page(paginator.num_pages)
    return render(request,'search/container_filter.html',{'response': response})

I'm recycling this code, but I'm trying to understand how to adapt it to get the label tag and the column for the filter?

      <div class="form-group col-sm-4 col-md-3">
        {{ response.form.container_type.label_tag }}
        {% render_field response.container_type class="form-control" %}
      </div>
garynobles
@garynobles
Jun 18 2018 12:25

I've tried :

  <div class="form-group col-sm-4 col-md-3">
          {{ response.paginator.filtered_qs.form.container_type.label_tag }}
          {% render_field response.paginator.filtered_qs.form.container_type class="form-control" %}
        </div>

without success

Luke-VideoLibre
@LukeVideo
Jun 18 2018 12:34
Hey using env variables is great. But it doesn't seem to work for debug settings. Is it because i export a string ? Is there a way of passing True from env ??? how do you handle that ? Thanks for any advise.
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 12:36
yes it is because env variable is a string
Luke-VideoLibre
@LukeVideo
Jun 18 2018 12:39
So i have to check that string and strore a proper boolean in another variable???
If ENV_DEBUG == "FALSE" : debug_var = False
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 12:40
you could do something like
if ENV  is "True":
  print("true")
else:
  print("false")
Luke-VideoLibre
@LukeVideo
Jun 18 2018 12:41
And add
if os.environ['ENV_DEBUG']  is  "FALSE" : 
    debug_var = False
else :
    debug_var = True
DEBUG = debug_var
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 12:44
yep
Luke-VideoLibre
@LukeVideo
Jun 18 2018 12:45
I'm pretty sure it could be prettier but that will be good enough.
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 12:46
keep in mind that using is matches the exact string so "FALSE" != "False"
Luke-VideoLibre
@LukeVideo
Jun 18 2018 12:47

Of course.
Could this work ?

DEBUG = os.environ['ENV_DEBUG']  is  "FALSE"

or am i stuck in JS land

Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 12:47
you could also just check if the ENV is set since an empty string evals to False
Luke-VideoLibre
@LukeVideo
Jun 18 2018 12:48
good point !
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 12:51
DEBUG = True if os.environ['ENV_DEBUG']
should work
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 12:57
nvm
tested and it doesn't
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 13:02
as stated here that isn't the Pythonic way anyways https://stackoverflow.com/questions/14105500/compressing-x-if-x-else-y-statement-in-python
Better to stick with the multiline if else statment since it is also easier to read.
DEBUG = False
if os.environ['ENV_DEBUG']: 
    DEBUG = True
Curtis Maloney
@funkybob
Jun 18 2018 13:22
DEBUG = 'ENV_DEBUG' in os.environ
since os.environ is dict-like
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 13:23
ah right
Curtis Maloney
@funkybob
Jun 18 2018 13:24
however
if ENV_DEBUG is set to empty... do you still want DEBUG to be true?
you could use bool(os.getenv('ENV_DEBUG'))
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 13:32
DEBUG = False
if os.environ['ENV_DEBUG']: 
    DEBUG = True
should still be the prefered way though since it is Pythonic and defaults to false unless set.
Curtis Maloney
@funkybob
Jun 18 2018 13:34
not sure why you feel it's more pythonic... and I already gave two solutions, one that's false unless set, and the other that's false unless set to non-blank
could even import strtobool from distutils.util if you want it to be finnicky...
what makes your way more pythonic than any other?
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 13:37
well there are lots of ways to do it, doesn't matter; I only felt it was easier to read and understand what was happening at a glance.
Curtis Maloney
@funkybob
Jun 18 2018 13:39
well, there is that...
after all, "Readability counts"
Brett MacDonald
@ArtistsTechGuy
Jun 18 2018 13:39
besides I'm not the one who asked so it truly doesn't matter much to me either way. I was just debating merits.
Curtis Maloney
@funkybob
Jun 18 2018 13:49
(honestly, I'm always suspicious of anyone who places trust in SO :)
Majekobaje Oluwaseyi
@blackgeeknerd
Jun 18 2018 17:59
So happy to be here
@funkybob Nice meeting u
Paul A. Aranguren
@Paulguren
Jun 18 2018 19:39
Hey guys, I’m having trouble relating any entries created in the DB to a specific user
I’m going to try and link the relevant info to see if any of you guys have any ides
views.py
def create_entry(request):
    createPath = 'log1/create_entry.html'
    if request.method == 'POST':  # good, a post (but no FILES check!)
        form = notarizerCreateForm(request.POST, request.FILES)
        if form.is_valid():
            instance = form.save()
            CustomUser.objects.create(user=instance)
        else:
            # you probably want to show the errors in that case to the user
            print(form.errors)
        # redirect to a page, for example the `page1 view
        return redirect(page1)
    else:
        form = notarizerCreateForm()
    return render(request, createPath, {'form': form})
log1/models.py
class notarizer(models.Model):
    date = models.DateField(auto_now_add=True)
    docName = models.CharField(max_length=25, null=False)
    describe = models.TextField(max_length=280)
    signee = models.CharField(max_length=25, null=False)
    signeeDets = models.TextField(max_length=280)
    copydoc = models.FileField(upload_to='users/', blank=True, null=True)
    userziptie = models.ForeignKey('users.CustomUser', on_delete=models.DO_NOTHING, null=True)
and then I use a modelForm to make that go through… please see below:
class notarizerCreateForm(ModelForm):
    class Meta:
        model = notarizer
        fields = ['docName','describe','signee','signeeDets', 'copydoc’]
I used a separate user model, per the django docs, they say that using a separate user model is always a good idea… so here is the basic user model i used
class CustomUser(AbstractUser):
    name = models.CharField(blank=True, max_length=255)


    def __str__(self):
        return self.username
Whenever I use the relevant form to submit an entry, it saves to the DB, but the user is supposed to be “selected” with a drop down, instead of it being tied to the user, and I’m stumped. Any ideas on how I could relate the entry to the user that is logged in? Sorry for the wall. Thank you