These are chat archives for django/django

19th
Sep 2017
:]
@elcolie
Sep 19 2017 04:40
@oguzhan-yilmaz Thanks. I just put in the first migration file. That's fine
Hi
In my model schema. I have created_user, and updated_user
And I would like to to log the DjangoAdmin user from doing change in the record.
What topic I should start?
Luke-VideoLibre
@LukeVideo
Sep 19 2017 09:59
Hi, I'm trying to use a password to generate a RSA keypair. I have the three fields in my model but in my form i only have a field for the password. In that case i use the view to crunch the numbers and save the computed keys?
Luke-VideoLibre
@LukeVideo
Sep 19 2017 10:05
I also wonder if the fields that are not in the form should have a blank=true so that the view could save each element one after the other?
maybe not just check them all and then save the lot ?
Milan Leon
@milanmaximo
Sep 19 2017 12:05
Does anyone have worked with payment gateway Banwire and API integration ? Thanks a lot
Kaushal Kumar
@kaushal087
Sep 19 2017 13:42
I have to validate django request. For that I am using https://webargs.readthedocs.io/en/latest/
It works fine if I use decorator like
class CouponCreate(APIView):
    @use_args(coupon_args, locations=('json', 'form'))
    def post(self, request):
but I am not able to catch its error
So I am using another method
from django.http import JsonResponse

from webargs import fields, ValidationError

argmap = {
    'name': fields.Str(required=True)
}
def index(request):
    try:
        args = parser.parse(argmap, request)
    except ValidationError as err:
        return JsonResponse(err.messages, status=err.status_code)
    return JsonResponse({'message': 'Hello {name}'.format(name=name)})
Kaushal Kumar
@kaushal087
Sep 19 2017 13:49
But now the error is
raise RawPostDataException("You cannot access body after reading from request's data stream")
How can I fix this error?
Please help
Sathish Kumar
@sathisz
Sep 19 2017 13:50
what type of validation
Kaushal Kumar
@kaushal087
Sep 19 2017 13:57
Request validation
got resolved
Sathish Kumar
@sathisz
Sep 19 2017 13:57
okay
Kaushal Kumar
@kaushal087
Sep 19 2017 13:58
args = parser.parse(argmap, request, locations=('json', 'form'))
work
Ali
@Qurus
Sep 19 2017 15:20

Hi I have created Form field for HomePage like this

class HomePageFormField(AbstractFormField):
    page = ParentalKey('home.HomePage', related_name='form_fields')

class HomePage(MetadataPageMixin, Page):
    body = StreamField(RiderStreamBlock())
    search_fields = Page.search_fields + [
        index.SearchField('body'),
    ]

    api_fields = ['body', 'carousel_items']

    class Meta:
        verbose_name = "Homepage"

HomePage.content_panels = [
    FieldPanel('title', classname="full title"),
    StreamFieldPanel('body'),
    InlinePanel('carousel_items', label="Carousel items"),
    InlinePanel('form_fields', label="Newsletter Form")

]

HomePage.promote_panels = Page.promote_panels

And rendering like this at home_page.html

<form class="validate" action="{% pageurl page %}" method="post" data-success="Subscribed! Thank you!" data-toastr-position="bottom-right">
                                        {% csrf_token %}    
                                        {% for field in form %}
                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-envelope"></i></span>
                                            {{ field|add_class:"form-control required" }}   <span class="input-group-btn">
                         <button class="btn btn-black" type="submit">Subscribe</button>
                  </span>
            </div>
        {% endfor %}
 </form>

But not rendering or showing on page. Could you please anyone tell me what can be causing that issue?