1

I set myself up on PythonAnywhere a few minutes ago. I go to the admin panel and attempt to create a new model instance, but when I click 'Save' I just get an unhelpful page with just Bad Request (400) on it.

I don't exactly know what I can provide to you to make it easier to understand and solve, so tell me if you want me to add something.

My model code:

class Frame(models.Model):
    name = models.TextField(max_length=16, unique=True)
    file_upload = models.FileField(upload_to='/media/')
    font = models.FileField(upload_to='/media/')
    text_size = models.IntegerField()
    slug = models.SlugField(unique=True)

    def save(self, *args, **kwargs):
        self.slug = slugify(self.name)
        super(Frame, self).save(*args, **kwargs)

    def __str__(self):
        return self.name

Only thing I could find in the logs relating to that:

x.x.x.x - - [12/Sep/2015:16:34:06 +0000] "POST /admin/generate/frame/add/ HTTP/1.1" 400 37 "http://x.pythonanywhere.com/admin/generate/frame/add/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36" "x.x.x.x"

Error log is empty and Server log has nothing but generic stuff.

@Glenn nope, either I set it to True or False it doesn't work. Also, it's all good and working until I go to /admin/generate/frame/add/ and attempt to save the form there. So, it's not a problem with the ALLOWED_HOSTS, even when I set it to a wildcard it doesn't work.

ca1ek
  • 405
  • 1
  • 4
  • 14
  • Pythonanywhere should provide you with an error log in the webapps tab. What does that log say? – conrad Sep 14 '15 at 14:04
  • @conrad I updated the post. – ca1ek Sep 15 '15 at 09:12
  • possible duplicate of [Django gives Bad Request (400) when DEBUG = False](http://stackoverflow.com/questions/19875789/django-gives-bad-request-400-when-debug-false) – Glenn Sep 15 '15 at 11:29
  • @Glenn nope, either I set it to True or False it doesn't work. Also, it's all good and working until I go to /admin/generate/frame/add/ and attempt to save the form there. – ca1ek Sep 16 '15 at 16:18
  • You didn't actually go to the question and read it and see the stuff about ALLOWED_HOSTS, did you? – Glenn Sep 16 '15 at 20:20
  • @Glenn It doesn't work even when debug is true. – ca1ek Sep 18 '15 at 11:23
  • Another possibility is that one of the paths for the FileFields is incorrect. Django will throw a SuspiciousOperationException which results in a 400 error. – Glenn Sep 18 '15 at 16:05
  • @Glenn Will check it, but shouldn't I get a stacktrace in that case? I edited the main post with updated code. – ca1ek Sep 19 '15 at 11:31
  • Very weird. You'd expect a stack trace, but maybe Django is swallowing it for some reason. Are you sure you have write permissions for the directories you're specifying for uploaded media? – Giles Thomas Sep 21 '15 at 15:42

0 Answers0