Saturday, October 22, 2016

Re: Am I missing a design pattern? My views code somehow isn't as elegant as it should be...

Class Based View really shine in form handling. You can find the
documentation at [1]. All the boilerplate code will be 3 assignment
like template_name = 'wizard/questionnaire.html' while the logic will
go into form_valid function.

I would also add a comment for the Matcher object and why the m
variable isn't used after the call to match.

[1] https://docs.djangoproject.com/en/1.10/topics/class-based-views/generic-editing/

2016-10-21 21:48 GMT+02:00 Andrew Chiw <randomshinichi4869@gmail.com>:
> As someone POSTs a questionnaire, I lookup some additional info about the IP
> and save that into a model's JSONField.
> I'm sending the request into django-ipware's get_ip(), which will return the
> IP address as a string. Since this data is ephemeral, I put it directly in
> the constructor instead of storing the return value in a variable.
> My bad, should've included the imports at the top of the file so you know
> where get_ip() comes from.
>
> On Friday, 21 October 2016 21:33:42 UTC+2, Alex Heyden wrote:
>>
>> Are you intentionally sending the whole request into that constructor and
>> concatenating it to a URL string? I can't imagine any way this doesn't end
>> in disaster.
>>
>> I'm sure the community would happily help, but it's not at all obvious
>> from the supplied code what you're trying to do here.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ad4ef983-3430-4058-ae24-e036cd6205f1%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTY0%3DLK-qZ1-zp4MqiWL6d7FRuGDhhyV_GUaQhtMMrEj-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment