django-settings

django media not loading

人盡茶涼 提交于 2019-12-11 18:01:31
问题 So using django for the first time and ran into this issue where the media url does not want to load/work so far my urls.py is setup like so if settings.DEBUG: urlpatterns += patterns('', (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),) my settings.py like so PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') MEDIA_URL = '/media/' ADMIN_MEDIA_PREFIX = 'http:/localhost:8000/admin-media/' my

Server error (500) Django deployment on heroku

对着背影说爱祢 提交于 2019-12-11 16:15:22
问题 I turned debug to False in my settings.py file (note that before I turned it to false, everything was workign perfectly) and when I ran git push heroku master and went to my website, the home page was working but that wasn't the case for all of my pages: on some, I got an error saying Server Error (500) Here is my settings.py code : DEBUG = False ALLOWED_HOSTS = ["hacka-labs.herokuapp.com"] What I have noticed is that the urls where I pass an id aren't working Please help me if you know the

Django manage.py collectstatic not uploading to google cloud storage

会有一股神秘感。 提交于 2019-12-11 12:49:04
问题 Experience level with issue This is my first experience with deploying static files and using Django. Issue When I run python manage.py collectstatic I will get the following result: 2 static files copied to '/home/ymorin007/workspace/sites/onbytes.com/onbytes-static', 151 unmodified, 4 post-processed. But nothing is beeing push to my bucket in google cloud storage. I'm not getting any errors in the terminal. Anything I'm missing her? My code I'm using django-storages This is the following

django using MEDIA URL in a template

爷,独闯天下 提交于 2019-12-11 11:14:17
问题 i'm trying to access files that were uploaded by users. i have the following settings: MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'project/media/') MEDIA_URL = '/project/media/' and the file are: path = models.FileField(upload_to="myApp") image = models.ImageField(upload_to="myApp/logos", null=True, blank=True) in the template i try to acces it in the following way: {{MEDIA_URL}}{{file.path}} but it doesn't work.. what am i doing wrong? 回答1: file.path returns an object representing the file,

Accessing request.META.SERVER_NAME in template

旧巷老猫 提交于 2019-12-11 05:26:49
问题 I call a template like this from my view: return render_to_response('mytemplate.html', context_instance=RequestContext(request)) I'm trying to access the hostname of my current server (in this case, localhost ), but it just prints blank when I place {{request.META.SERVER_NAME}} in the template. In my settings.py file, I don't have any TEMPLATE_CONTEXT_PROCESSORS defined. I'm not sure if I need to specify anything there, or if that could solve the problem. 回答1: You have to add the request

ImportError: No module named app_name

萝らか妹 提交于 2019-12-11 05:07:55
问题 I am new to python and I have seen similar questions on SO but not able to figure out whats wrong with my Django app. In settings.py I have added my app in dotted module form : INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mproject.blog', ) and the Traceback : D:\py pro\mproject>python manage.py runserver 9999 Traceback (most recent call last): File "manage

Can I define classes in Django settings, and how can I override such settings in tests?

女生的网名这么多〃 提交于 2019-12-11 04:26:53
问题 We are using Django for Speedy Net and Speedy Match (currently Django 1.11.17, we can't upgrade to a newer version of Django because of one of our requirements, django-modeltranslation). I want to define some of our settings as classes. For example: class UserSettings(object): MIN_USERNAME_LENGTH = 6 MAX_USERNAME_LENGTH = 40 MIN_SLUG_LENGTH = 6 MAX_SLUG_LENGTH = 200 # Users can register from age 0 to 180, but can't be kept on the site after age 250. MIN_AGE_ALLOWED_IN_MODEL = 0 # In years.

Django 1.4.1 error loading MySQLdb module when attempting 'python manage.py shell'

只愿长相守 提交于 2019-12-11 01:58:21
问题 I am trying to set up MySQL, and can't seem to be able to enter the Django manage.py shell interpreter. I did install MySQL-python but that did not solve the issue. Getting the output below: rrdhcp-10-32-44-126:django pavelfage$ python manage.py shell Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in

Django not able to find the static files when using django-allauth

元气小坏坏 提交于 2019-12-10 16:06:40
问题 When I use allauth, everything seems to work fine except that Django is now unable to find the static files. Without allauth all the static files are being rendered. the settings for allauth requires to add TEMPLATE_CONTEXT_PROCESSORS = ( "allauth.context_processors.allauth", "allauth.account.context_processors.account" ) I did not have TEMPLATE_CONTEXT_PROCESSORS in my settings file earlier. Is there something that I am missing? How should I solve this problem. When I see the DEBUG console I

django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth'

南笙酒味 提交于 2019-12-10 14:48:31
问题 I started a new project and am getting: django.core.exceptions.ImproperlyConfigured: Enable 'django.contrib.auth.context_processors.auth' in your TEMPLATES setting in order to use the admin application. I followed the django docs for 1.9: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, } ] What could be the issue (how does it want me configure)? Thank you 回答1: You need to add it into context