jazzband / django-robots

A Django app for managing robots.txt files following the robots exclusion protocol
https://django-robots.readthedocs.io
BSD 3-Clause "New" or "Revised" License
457 stars 97 forks source link

Not able to create Url with model_bakery: too long pattern throws exception #132

Closed PetrDlouhy closed 9 months ago

PetrDlouhy commented 2 years ago

If I try to create Url model with model_bakery without any parameters, I have got this error:

django.db.utils.DataError: value too long for type character varying(255)

The problem is, that pattern parameter (generated by model_bakery) gets lengthen in save() method by leading / and doesn't fit in the field anymore.

The solution is very simple: add default="" to the pattern field.

There is also second problem with the save method - if user enters pattern exactly 255 characters long in the admin, it will throw an exception rather than showing validation error.

tony commented 1 year ago

model_backery: GitHub, docs