Thanks Steve!
On Wed, Jan 22, 2014 at 12:22 PM, Stephen McDonald <[email protected]> wrote: > Thanks Josh - fixed here: > https://github.com/stephenmcd/mezzanine/commit/9f8a125bdb74f24664d9939ca63fa2876cebbd9c > > > On Thu, Jan 23, 2014 at 6:37 AM, Josh Cartmell <[email protected]>wrote: > >> Ok, I dug into this more and the IP that is trying to be saved is coming >> from mezzanine.utils.views.ip_for_request. I just monkey patched it like >> this: >> >> def new_ip_for_request(request): >> """ >> Returns ip address for request - first checks ``HTTP_X_FORWARDED_FOR`` >> header, since app will generally be behind a public web server. >> """ >> meta = request.META >> ip = meta.get("HTTP_X_FORWARDED_FOR", >> meta["REMOTE_ADDR"]).split(',')[0] >> return ip >> >> views.ip_for_request = new_ip_for_request >> >> A comment in the code of the "What's middleware" section of >> http://www.djangobook.com/en/2.0/chapter17.html says that >> HTTP_X_FORWARDED_FOR can be a comma separated list of ips, in my case it >> was, which was causing the error. >> >> Does anyone else have thoughts on this? I'm thinking we should update >> the ip_for_request in Mezzanine. >> >> >> On Wed, Jan 22, 2014 at 10:29 AM, Josh Cartmell <[email protected]>wrote: >> >>> I have a Mezzanine site I put up recently and occasionally when someone >>> tries to save a comment the following error is produced: >>> >>> Traceback (most recent call last): >>> >>> File ".../site-packages/django/core/handlers/base.py", line 114, in >>> get_response >>> response = wrapped_callback(request, *callback_args, >>> **callback_kwargs) >>> >>> File ".../site-packages/mezzanine/generic/views.py", line 98, in >>> comment >>> comment = form.save(request) >>> >>> File ".../site-packages/mezzanine/generic/forms.py", line 133, in save >>> comment.save() >>> >>> File ".../site-packages/mezzanine/generic/models.py", line 56, in save >>> super(ThreadedComment, self).save(*args, **kwargs) >>> >>> File ".../site-packages/django/contrib/comments/models.py", line 88, >>> in save >>> super(Comment, self).save(*args, **kwargs) >>> >>> File ".../site-packages/django/db/models/base.py", line 545, in save >>> force_update=force_update, update_fields=update_fields) >>> >>> File ".../site-packages/django/db/models/base.py", line 572, in >>> save_base >>> self._save_parents(cls, using, update_fields) >>> >>> File ".../site-packages/django/db/models/base.py", line 597, in >>> _save_parents >>> self._save_table(cls=parent, using=using, >>> update_fields=update_fields) >>> >>> File ".../site-packages/django/db/models/base.py", line 654, in >>> _save_table >>> result = self._do_insert(cls._base_manager, using, fields, >>> update_pk, raw) >>> >>> File ".../site-packages/django/db/models/base.py", line 687, in >>> _do_insert >>> using=using, raw=raw) >>> >>> File ".../site-packages/django/db/models/manager.py", line 232, in >>> _insert >>> return insert_query(self.model, objs, fields, **kwargs) >>> >>> File ".../site-packages/django/db/models/query.py", line 1511, in >>> insert_query >>> return query.get_compiler(using=using).execute_sql(return_id) >>> >>> File ".../site-packages/django/db/models/sql/compiler.py", line 898, >>> in execute_sql >>> cursor.execute(sql, params) >>> >>> File ".../site-packages/django/db/backends/util.py", line 53, in >>> execute >>> return self.cursor.execute(sql, params) >>> >>> File ".../site-packages/django/db/utils.py", line 99, in __exit__ >>> six.reraise(dj_exc_type, dj_exc_value, traceback) >>> >>> File ".../site-packages/django/db/backends/util.py", line 53, in >>> execute >>> return self.cursor.execute(sql, params) >>> >>> DataError: invalid input syntax for type inet: "xxx.xxx.xx.xxx, >>> xxx.xxx.xxx.xxx" >>> LINE 5: ...your name.', E'2014-01-22 18:23:28.661696+00:00', >>> E'xxx.xxx.... >>> >>> I've redacted the actual IP address. I'm geussing that it has something >>> to do with the presence of two address (that's just speculation). Has >>> anyone else ever seen this? Or does anyone else have any ideas about what >>> is going on or how I could prevent it? >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Mezzanine Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > Stephen McDonald > http://jupo.org > > -- > You received this message because you are subscribed to the Google Groups > "Mezzanine Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
