django-errors

Django give Error 500 for all static files like CSS and Images, when DEBUG is False

点点圈 提交于 2020-12-21 04:05:47
问题 I've tried different solutions already posted by users, but they didn't work for me. settings.py of Project BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False ALLOWED_HOSTS = ["*"] STATIC_URL = '/static/' STATICFILES_DIRS=[ os.path.join(BASE_DIR,'static') ] STATIC_ROOT=os.path.join(BASE_DIR,'assets') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') All my CSS files are in style folder inside the static folder. And all images are in the media

Django give Error 500 for all static files like CSS and Images, when DEBUG is False

旧城冷巷雨未停 提交于 2020-12-21 04:05:33
问题 I've tried different solutions already posted by users, but they didn't work for me. settings.py of Project BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False ALLOWED_HOSTS = ["*"] STATIC_URL = '/static/' STATICFILES_DIRS=[ os.path.join(BASE_DIR,'static') ] STATIC_ROOT=os.path.join(BASE_DIR,'assets') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') All my CSS files are in style folder inside the static folder. And all images are in the media

Django give Error 500 for all static files like CSS and Images, when DEBUG is False

痞子三分冷 提交于 2020-12-21 04:04:56
问题 I've tried different solutions already posted by users, but they didn't work for me. settings.py of Project BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False ALLOWED_HOSTS = ["*"] STATIC_URL = '/static/' STATICFILES_DIRS=[ os.path.join(BASE_DIR,'static') ] STATIC_ROOT=os.path.join(BASE_DIR,'assets') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') All my CSS files are in style folder inside the static folder. And all images are in the media

Django Error: __init__() got multiple values for keyword argument 'max_length'

╄→尐↘猪︶ㄣ 提交于 2019-12-24 13:57:08
问题 I am getting this error. I do not understand the head and tail of it. __init__() got multiple values for keyword argument 'max_length' . I am adding three fields to UserCreationForm from django.contrib.auth.forms , which are email , first name and last name and I want to save them to my User object. (Does the first name and last name gets saved automatically). Here is my form that I am trying to load. class MyRegistrationForm(UserCreationForm): #define fields email=forms.EmailField(required

Catching Any DoesNotExist Error

南笙酒味 提交于 2019-12-24 01:48:32
问题 I am using Django 1.7. Normally you can catch DoesNotExist exception over your model like; try: ... except model.DoesNotExist, den: ... I want to catch any DoesNotExist exception. I really don't want to care about its model. Actually, I really don't know which model DoesNotExist is passing through the code piece either. I mean, I am not able to know the model. So I have to catch any DoesNotExist error somehow. Is there a way to catch any DoesNotExist error in Django ? 回答1: DoesNotExist

Django Error Reporting - How to know which user triggered the error?

笑着哭i 提交于 2019-12-21 09:23:29
问题 Is there a way I can customize Django error reporting so when it emails me it lets me know which user triggered the error? I'm in Django 1.2 if it matters. Much Thanks in advance! 回答1: If you don't want to use sentry you can use this simple middleware to attache the user-infos to the error mail: # source: https://gist.github.com/646372 class ExceptionUserInfoMiddleware(object): """ Adds user details to request context on receiving an exception, so that they show up in the error emails. Add to

Multiple strings with str_detect R

泪湿孤枕 提交于 2019-12-21 03:31:00
问题 I want to find multiple strings and put it in a variable, however I keep getting errors. queries <- httpdf %>% filter(str_detect(payload, "create" || "drop" || "select")) Error: invalid 'x' type in 'x || y' queries <- httpdf %>% filter(str_detect(payload, "create" | "drop" | "select")) Error: operations are possible only for numeric, logical or complex types queries1 <- httpdf %>% filter(str_detect(payload, "create", "drop", "select")) Error: unused arguments ("drop", "select") None of these

Using django_comments but getting 'QuerySet' object has no attribute '_meta'

南笙酒味 提交于 2019-12-13 06:08:34
问题 My django project named comments is here. It has an app comms which is there to display comments using django_comments . I have installed django_comments put it in INSTALLED_APPS field in settings.py have defined SITE_ID = 1 enabled the sites framework put url(r'^comments/', include('django_comments.urls')) in urls.py But this template file is giving me this error: AttributeError at / 'QuerySet' object has no attribute '_meta' What am I missing? 回答1: Change your home.html to something like: {

Trouble closing and reopening MySQL connection after catching/handling django.db.utils.OperationalError (2013, Lost connection to server)

人走茶凉 提交于 2019-12-11 06:58:39
问题 I getting a django.db.utils.OpertionalError: (2013, Lost connection to MySQL Server) . The reason is because the MAX_TIMEOUT is set to 90 seconds. I'm attempting to catch the error, close the bade connection, and make a fresh query. I would think the following try/except block would catch the error, close the connection and try the same query a second time: try: sku = SkuLight.objects.filter(expansion=card_set).filter(name=card_name) except OperationalError as e: print(e) connection.close()

'AdminSite' object has no attribute 'root'

我只是一个虾纸丫 提交于 2019-12-11 05:03:03
问题 Environment: Request Method: GET Request URL: http://54.235.168.5/mds/ Django Version: 1.3.1 Python Version: 2.7.3 Installed Applications: ['sana.mrs', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'sana.mrs.util.LoggingMiddleware'