django-settings

Django - after login, redirect user to his custom page --> mysite.com/username

眉间皱痕 提交于 2019-11-26 18:37:24
By default after login django redirects the user to an accounts/profile page or if you edit the LOGIN_REDIRECT_URL you can send the user to another page you specify in the settings.py. This is great but I would like the user (after login) to be redirected to a custom page where the link to that page would look something like this: mysite.com/username . So the default accounts/profile or the LOGIN_REDIRECT_URL settings would not work in this case since both are somehow static. In my case the username section of the address changes for every user. Any ideas how I can make it so when the user is

How to set up a PostgreSQL database in Django

百般思念 提交于 2019-11-26 10:06:01
问题 I\'m new to Python and Django. I\'m configuring a Django project using a PostgreSQL database engine backend, But I\'m getting errors on each database operation. For example when I run manage.py syncdb , I\'m getting: C:\\xampp\\htdocs\\djangodir>python manage.py syncdb Traceback (most recent call last): File \"manage.py\", line 11, in <module> execute_manager(settings) File \"C:\\Python27\\lib\\site-packages\\django\\core\\management\\__init__.py\", line 438, in execute_manager utility

How to set-up a Django project with django-storages and Amazon S3, but with different folders for static files and media files?

点点圈 提交于 2019-11-26 07:53:17
问题 I\'m configuring a Django project that were using the server filesystem for storing the apps static files ( STATIC_ROOT ) and user uploaded files ( MEDIA_ROOT ). I need now to host all that content on Amazon\'s S3, so I have created a bucket for this. Using django-storages with the boto storage backend, I managed to upload collected statics to the S3 bucket: MEDIA_ROOT = \'/media/\' STATIC_ROOT = \'/static/\' DEFAULT_FILE_STORAGE = \'storages.backends.s3boto.S3BotoStorage\' AWS_ACCESS_KEY_ID

Can I access constants in settings.py from templates in Django?

六眼飞鱼酱① 提交于 2019-11-26 05:36:18
I have some stuff in settings.py that I'd like to be able to access from a template, but I can't figure out how to do it. I already tried {{CONSTANT_NAME}} but that doesn't seem to work. Is this possible? Django provides access to certain, frequently-used settings constants to the template such as settings.MEDIA_URL and some of the language settings if you use django's built in generic views or pass in a context instance keyword argument in the render_to_response shortcut function. Here's an example of each case: from django.shortcuts import render_to_response from django.template import

Can I access constants in settings.py from templates in Django?

ぐ巨炮叔叔 提交于 2019-11-26 01:55:26
问题 I have some stuff in settings.py that I\'d like to be able to access from a template, but I can\'t figure out how to do it. I already tried {{CONSTANT_NAME}} but that doesn\'t seem to work. Is this possible? 回答1: Django provides access to certain, frequently-used settings constants to the template such as settings.MEDIA_URL and some of the language settings if you use django's built in generic views or pass in a context instance keyword argument in the render_to_response shortcut function.