django-templates

How to load static files on heroku server?

倾然丶 夕夏残阳落幕 提交于 2021-01-25 07:11:03
问题 I have successfully deployed my django project on heroku but my project is not looking as it looks on local server due to static files i guess. I am using django 3.1.4. And having issues with version control. here what its look on local : here what its look on server : settings.py: STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATIC_ROOT = BASE_DIR / 'staticfiles' STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / "static", '/var/www/static/', ] if more

How to load static files on heroku server?

吃可爱长大的小学妹 提交于 2021-01-25 07:10:42
问题 I have successfully deployed my django project on heroku but my project is not looking as it looks on local server due to static files i guess. I am using django 3.1.4. And having issues with version control. here what its look on local : here what its look on server : settings.py: STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATIC_ROOT = BASE_DIR / 'staticfiles' STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / "static", '/var/www/static/', ] if more

How to load static files on heroku server?

拈花ヽ惹草 提交于 2021-01-25 07:10:08
问题 I have successfully deployed my django project on heroku but my project is not looking as it looks on local server due to static files i guess. I am using django 3.1.4. And having issues with version control. here what its look on local : here what its look on server : settings.py: STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATIC_ROOT = BASE_DIR / 'staticfiles' STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / "static", '/var/www/static/', ] if more

How to load static files on heroku server?

Deadly 提交于 2021-01-25 07:07:26
问题 I have successfully deployed my django project on heroku but my project is not looking as it looks on local server due to static files i guess. I am using django 3.1.4. And having issues with version control. here what its look on local : here what its look on server : settings.py: STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATIC_ROOT = BASE_DIR / 'staticfiles' STATIC_URL = '/static/' STATICFILES_DIRS = [ BASE_DIR / "static", '/var/www/static/', ] if more

Display Django form fields on the “same line”

╄→尐↘猪︶ㄣ 提交于 2021-01-22 06:36:10
问题 I would like to display two form fields on the same line and not each one after the other one. For the moment, I get: Choice a theme : . Datasystems . Cameroun But I would like to display this form like: Choice a theme: . Datasystems . Cameroun My .html file looks like : {% extends 'Base_Configurations.html' %} {% load staticfiles %} {% load static %} {% block title %} <h3> <span class="glyphicon glyphicon-file"></span> Choix du thème DatasystemsEC </align> </h3> {% endblock %} {% block

Django: Passing object from template to views

北战南征 提交于 2021-01-21 11:21:18
问题 I want to use the same template to view information about each of my database objects. I would like to be able to click on each element in the list and have it link me to a page with info about it. I'm thinking there's an easier way than making a view for each unique object. I'm listing all of my database objects on my list.html like this: {% for instance in object_info %} <li><a href="object">{{ instance.name }}</a></li> {% endfor %} My views.py has this view: def object_view(request): data

Django: Passing object from template to views

社会主义新天地 提交于 2021-01-21 11:19:07
问题 I want to use the same template to view information about each of my database objects. I would like to be able to click on each element in the list and have it link me to a page with info about it. I'm thinking there's an easier way than making a view for each unique object. I'm listing all of my database objects on my list.html like this: {% for instance in object_info %} <li><a href="object">{{ instance.name }}</a></li> {% endfor %} My views.py has this view: def object_view(request): data

Difference between auto_now and auto_now_add

核能气质少年 提交于 2021-01-20 23:41:09
问题 What I understood in Django models field's attributes is auto_now - updates the value of field to current time and date every time the Model.save() is called. auto_now_add - updates the value with the time and date of creation of record. My question is what if a filed in model contains both the auto_now and auto_now_add set to True? What happens in that case? 回答1: auto_now takes precedence (obviously, because it updates field each time, while auto_now_add updates on creation only). Here is

Django date to javascript at the template

北城以北 提交于 2021-01-20 23:31:09
问题 What would be the easy way of achieving such below? selected_date comes from django context as a python date : <script type="text/javascript"> var selected_year = {{ selected_date|date:"Y" }} var selected_month = {{ selected_date|date:"m" }} - 1; var selected_day = {{ selected_date|date:"d"}} var selected_date = new Date(selected_year, selected_month, selected_day); alert(selected_date); </script> 回答1: I've had a lot of success with the isoformat function in python: var selected_date = new

How to get the name of current app within a template?

孤者浪人 提交于 2021-01-20 17:52:19
问题 What's the simplest way to access the name of the current app within template code? Alternatively, what's the simplest way to define a template variable to hold the name of the current app? (The goal here is to minimize the number of places I need to edit if I rename an app.) 回答1: There's a way to obtain an app name for a current request. First, in your project's urls.py, considering your app is called 'main' : #urls.py url(r'^', include('main.urls', app_name="main")), Then, a context