B
B
Bulbashful2016-05-21 01:23:58
PostgreSQL
Bulbashful, 2016-05-21 01:23:58

Why is there an error on POST?

Implementing standard django comments. I am using postgresql. On the server, when you try to add a comment, the following appears:

DataError at /comments/post/
invalid input syntax for type inet: "b''"
LINE 1: ... '2016-05-20T21:51:21.447504+00:00'::timestamptz, 'b'''''::i...

Form with comments
<form action="{% comment_form_target %}" method="post">

        {% csrf_token %}
        {% for field in form.hidden_fields %}
            {{ field }}
        {% endfor %}
        {% for field in form.visible_fields %}
            <div class="form-field">
                {% if field.errors.count > 0 %}
                <div class="error-list">
                    {{field.errors}}
                </div>
                {% endif %}
                {% if field.name == "honeypot" %}
                    <div id="honeyput">{{ field }}</div>
                {% else %}
                    <div class="label"> {{ field.label }} </div>
                    <div class="control">{{ field }}</div>
                {% endif %}
            </div>
        {% endfor %}
        <br>
        <div class="submit-button"><input type="submit"  class="btn btn-default" name="submit" value="Отправить"> </div>
    </form>
{% endblock %}

settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'det_sad',
        'USER': 'pavel',
        'PASSWORD':'pavel',
        'HOST': 'localhost',
        'PORT': '',
    }
}

nginx
server {
    listen 80;
    server_name detsky-sadik.ru;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/pavel/myproject;
    }

    location /media/ {
        root /home/pavel/myproject;
    }


    location / {
        include proxy_params;
        proxy_pass http://unix:/home/pavel/myproject/myproject.sock;
    }
}

generated form
<form action="/comments/post/" method="post">
        <input type='hidden' name='csrfmiddlewaretoken' value='fJ59okEuDEYxKFPUORChHIcitXFcf1Qa' />
        
            <input id="id_content_type" name="content_type" type="hidden" value="article.article" />
        
            <input id="id_object_pk" name="object_pk" type="hidden" value="1" />
        
            <input id="id_timestamp" name="timestamp" type="hidden" value="1463806250" />
        
            <input id="id_security_hash" maxlength="40" name="security_hash" type="hidden" value="cf5846c5f8eb920a5fe4569c61d84c426226b0c8" />
        
        
            <div class="form-field">
                
                
                    <div class="label"> Имя </div>
                    <div class="control"><input id="id_name" maxlength="50" name="name" type="text" /></div>
                
            </div>
        
            <div class="form-field">
                
                
                    <div class="label"> Адрес электронной почты </div>
                    <div class="control"><input id="id_email" name="email" type="email" /></div>
                
            </div>
        
            <div class="form-field">
                
                
                    <div class="label"> URL </div>
                    <div class="control"><input id="id_url" name="url" type="url" /></div>
                
            </div>
        
            <div class="form-field">
                
                
                    <div class="label"> Комментарий </div>
                    <div class="control"><textarea cols="40" id="id_comment" maxlength="3000" name="comment" rows="10">
</textarea></div>
            
            </div>
        
            <div class="form-field">
                    <div id="honeyput"><input id="id_honeypot" name="honeypot" type="text" /></div>          
            </div>
        <div class="submit-button"><input type="submit"class="btn btn-default" name="submit" value="Отправить"> </div>
    </form>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2016-05-21
@rostel

you are trying to push something completely different from the ip subnet into the field with the "inet" type

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question