These are chat archives for django/django

25th
Jun 2018
:]
@elcolie
Jun 25 2018 04:04
@iamsuneeth My application start and stop by script and I bundle them in single file. After that everything is control from here. You might need to use docker for this sort of job.
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 04:19
@ErickAgrazal Thanks man!
<django.forms.widgets.TextInput object at 0x03539CF0>
I got this when I rendered: {{ form.name }}. Any idea, why?
Salar Rahmanian
@softinio
Jun 25 2018 06:18
@thesanjeevsharma have you considered using wagtail ?
Megh Thakkar
@Megh-Thakkar
Jun 25 2018 06:22
@thesanjeevsharma if you want in place formatting in the admin panel, you can have a look at RichTextField, integrated with ckeditor. Does marvels!
Salar Rahmanian
@softinio
Jun 25 2018 06:23
Megh Thakkar
@Megh-Thakkar
Jun 25 2018 06:24
Yes @thesanjeevsharma , if your requirement is blog centric, puput is also great.
garynobles
@garynobles
Jun 25 2018 08:02
For some reason this form will not save, when I use {{form}} it has no problems.
{% extends 'processing3d/base.html' %}
{% load widget_tweaks %}
{% block content %}
<div class="container">
    <h1>Container</h1>
    <div class="col-sm-3">
    <form method="POST" class="post-form">{% csrf_token %}

      <div class="">
        <label for="inputFirstname">Photobatch</label>
        {% render_field form.photobatch_id class="form-control" %}
      </div>
      <div class="">
        <label for="inputFirstname">Prefix</label>
        {% render_field form.prefix class="form-control" %}
      </div>

        <button type="submit" class="save btn btn-default">Save</button>
    </form>
  </div>
</div>

{% endblock %}
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 08:13
@garynobles shouldn't there be an 'action' attribute in the form tag?
garynobles
@garynobles
Jun 25 2018 08:21
@thesanjeevsharma I'm using the forms.py what action should I add? action=""
garynobles
@garynobles
Jun 25 2018 08:29
Here's the views.py
def createprocessing3d(request):
    if request.method == "POST":
        form = Processing3dForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.created_by = request.user
            #post.modified_by = request.user
            post.created_timestamp = datetime.datetime.now()
            post.save()
            return redirect('processing3dpage')
    else:
        form = Processing3dForm()
    return render(request, 'processing3d/create_processing3d.html', {'form': form})
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 08:49
@garynobles the url that call this function 'createprocessing3d'.
Suneeth Lenin
@iamsuneeth
Jun 25 2018 09:02
@elcolie yes, I understood. I am doing the same nowm Thanks a lot
garynobles
@garynobles
Jun 25 2018 09:03
so
action = "{% createprocessing3d %}"
or
action ="{{createprocessing3d}}"
oh as a url
@thesanjeevsharma no, <form method="POST" action="{% url 'processing3dpage' %}" class="post-form">{% csrf_token %} does not work
`
garynobles
@garynobles
Jun 25 2018 09:15
@thesanjeevsharma I have return redirect('processing3dpage') so action is not required?
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 13:10
email = request.POST.get('email')
 sub = Subscriber()
 sub['email'] = str(email)
 sub.save()
How can I save objects manually? Even sub.email doesn't work!
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 13:30
@elcolie
<django.forms.widgets.TextInput object at 0x03539CF0>
I got this when I rendered: {{ form.name }}. Any idea, why?
:]
@elcolie
Jun 25 2018 13:31
@thesanjeevsharma Insufficient information. Do you have your simplify source code that I can run?
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 13:31
I'll just paste it here!
html page
<form class="col s12 m12" action="/contact/" method="post">
      {% csrf_token %}
      <div class="row">
        <div class="input-field col s12 m6">
          {{ form.name }}
          <label for="{{ form.name.id_for_label }}">Name</label>
        </div>
        <div class="input-field col s12 m6">
          {{ form.email }}
          <label for="{{ form.email.id_for_label }}">Email</label>
        </div>
      </div>
      <div class="row">
        <div class="input-field col s12 m12">
          {{ form.subject }}
          <label for="{{ form.subject.id_for_label }}">Subject</label>
        </div>
      </div>
      <div class="row">
        <div class="input-field col s12 m12">
          {{ form.message }}
          <label for="{{ form.message.id_for_label }}">Message</label>
        </div>
      </div>
      <div class="row">
        <div class="input-field col s12 m12">
          <input type="submit" value="send" class="subsribe-btn">
        </div>
      </div>
    </form>
views.py
def contact(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/contact-thanks/')
    else:
        form = ContactForm()

    return render(request, 'contact.html', {'form': form})
forms.py
from django import forms

class ContactForm(forms.Form):
    name = forms.TextInput(attrs={'size': 30, 'title': 'Name', 'required' : True})
    email = forms.EmailInput(attrs={'size': 50, 'title': 'Email', 'required' : True})
    subject = forms.TextInput(attrs={'size': 100, 'title': 'Subject', 'required' : True})
    message = forms.Textarea()
Abdelkader Belcaid
@p4p1lio_twitter
Jun 25 2018 13:55
hello
i need help
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
  95.       (error, imported_key) = key_import(gpg, keyfile)
File "/home/abdelkader/Desktop/GGVote/gpgvote/../gpgvote/gpgauth/views.py" in key_import
  51.       if gpg.key_is_expired(fp):

Exception Type: AttributeError at /register/
Exception Value: 'GPG' object has no attribute 'key_is_expired'
this is my traceback
i tried to upload a public key to register and got this error
:]
@elcolie
Jun 25 2018 14:02
image.png
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 14:03
@elcolie But how? I get that object name displayed.
:]
@elcolie
Jun 25 2018 14:04
@thesanjeevsharma No idea. But you can checkout and compare my code with yours. Here it is
git@github.com:elcolie/tryDj2.git
Good luck
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 14:04
@elcolie Thanks man! :0
:]
@elcolie
Jun 25 2018 14:05
@p4p1lio_twitter import pdb; pdb.set_trace() to do debugging. This is not difficult to debug
I suggest ipdb is a better package than origianl pdb
Abdelkader Belcaid
@p4p1lio_twitter
Jun 25 2018 14:06
where ?
which file
settings.py or manage.py ?
:]
@elcolie
Jun 25 2018 14:07
@p4p1lio_twitter /home/abdelkader/Desktop/GGVote/gpgvote/../gpgvote/gpgauth/views.py
Abdelkader Belcaid
@p4p1lio_twitter
Jun 25 2018 14:07
ok
Sanjeev Sharma
@thesanjeevsharma
Jun 25 2018 14:13
@elcolie It worked man! I was working with new django doc... you did it with old method. But it works. :)
Abdelkader Belcaid
@p4p1lio_twitter
Jun 25 2018 14:14
(ggvote) root@ubuntu:~/Desktop/GGVote/gpgvote# python manage.py runserver
Validating models...
0 errors found

Django version 1.2.1, using settings 'gpgvote.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
> /home/abdelkader/Desktop/GGVote/gpgvote/gpgauth/views.py(18)<module>()
-> def delete_keys(gpg, fingerprints, del_existed=False):
(Pdb)
what to do ?
:]
@elcolie
Jun 25 2018 14:20
@p4p1lio_twitter You are in the pdb now
You are free to use python syntax to investigate your bug
@p4p1lio_twitter Press c to continue. n to next line, q to quit
Good luck
Abdelkader Belcaid
@p4p1lio_twitter
Jun 25 2018 14:21
if gpg.key_is_expired(fp):
problem is here
Christopher Sabater Cordero
@cs-cordero
Jun 25 2018 19:09
What is a DeferredAttribute?
class Foo(models.Model):
    foo = models.CharField()

print(Foo.foo)   #  <django.db.models.query_utils.DeferredAttribute object at 0x112215d30>
why wouldn't it be a CharField?