django admin site showing with out format - python

I have a django test site and I can see the admin site, but it has different formatting from the tutorial examples.
This is how my admin site looks:
But on the example it looks like this:
What is missing to show the correct formatting?

Looks like your CSS file isn't being loaded. Make sure your django install is set up correctly to server out static files. The CSS file, by default, is in /static/admin/css.

uncomment 'django.contrib.staticfiles' under INSTALLED_APPS from settings.py.

Related

django geoposition map doesn't appear in admin

I'm using django-geoposition in a project and added it to my admin with a GeopositionField() in my models.py.
class MyClass(models.Model):
position = GeopositionField()
When I access it, it shows the lat, long field, but not the google map.
There are no errors in the browser console.
I have the application configured correctly in settings.py: INSTALLED_APPS and GEOPOSITION_GOOGLE_MAPS_API_KEY.
Django version==1.11.5
What can cause this?
It's a django-geoposition problem.
I found it and a workaround in:
https://github.com/philippbosch/django-geoposition/issues/83

Customizing Example Django App - Django Dev Pattern

I followed all 42 tutorials on the Try Django Youtube channel, and I'm trying to customize that project to make my own custom app.
My web app only needs two pages for now. One for users (which I only create in the admin) to log in, and another page to use the app. I'm trying to get the hang of the Django dev steps. Correct me if I'm wrong, so if I want to make a single page in a Django web app, I need to set it up in my urls.py, views.py, and make a template html file for it, right?
If I'm getting this order wrong or leaving anything out, any help or advice is appreciated. Can this pattern be found on Django documentation website, too?
Django based on MTV (model, view, template) pattern. More about it here http://aijogja.pythonblogs.com/251_aijogja/archive/1433_django_tutorial-create_a_blog-part_6__mvt_model_view_template_section_1-homepage.html
For adding another page, setup route in urls.py (write regexp), add function in views.py (must return httpresponse) and create template.html

How to use the Django-Scheduler package?

I am looking to use the Django-Scheduler package in my Django project but am finding it difficult to understand how to actually implement the calendar so that it can be seen on the actual website. My website is meant to be a timetable scheduling system where users can login and use and edit there own timetable/calendar. I have already implemented the login and registrastion using django registration redux. I have also already installed django-scheduler using pip and have edited my projects settings like so:
INSTALLED_APPS += ('schedule',)
add to
TEMPLATE_CONTEXT_PROCESSORS += (
"django.core.context_processors.request",
)
This is explained on the github page for django-scheduler. I have read through the documentation but am still not sure as to how to have a usable calendar on the page the user is sent to after logging in.
Could someone please explain to me as to how I can achieve this. What do I put in my projects url.py file for django-scheduler like eg the url for django-calendarium,
url(r'^calendar/', include('calendarium.urls')),
Do I have to create new templates etc.
Hope somebody can help ! Thanks
this will serve you
url(r'^calendar/', include('schedule.urls')),
if you still to know more about the url, views, models and config of schedule check https://github.com/llazzaro/django-scheduler/tree/develop/schedule and https://github.com/llazzaro/django-scheduler/tree/develop/schedule/urls.py for

How would you go about creating a "config" class in Django?

I'm making a very very reusable CMS in Django. I'm trying not to hardcode anything, so I want a config.py or something for the app itself.
I want to use it in templates (something like {{ config.SITE_NAME }}) and just regular Python code (views, models), etc.
How would I go about doing that?
Django already has the settings.py file and an interface to use the values from there, is that not good enough? Accessing settings in your code is easy:
from django.conf import settings
do_something_with(settings.MY_CONFIG_VARIABLE)
In your template it requires a bit more work, like making a context processor for example. This answer shows you have to make a context processor that exposes values from settings to your template.
settings.py serves this purpose already in django. You can add custom settings to it for your application.
https://docs.djangoproject.com/en/dev/topics/settings/#using-settings-in-python-code
When you create a django project, it automatically creates a settings.py file. Put your settings in that file, and then :-
from django.conf import settings
settings.YOUR_SETTING
also, if you have some settings, that will vary depending upon the machines (eg. production/test servers).
Then just add eg. conf/local_settings.py file and put the machine specific settings in that file, and in settings.py just do :-
from conf.local_settings import *
at the end of settings.py
Make sure you ignore local_settings.py from your VCS check-in (eg. in case of git add local_settings.py to .gitignore

How to use the default template for Django admin?

I installed Django and enabled the admin site. When I go to the admin page, I get the following
The image does not look the official Django tutorial. In settings.py I updated TEMPLATE_DIRS with the correct path.
TEMPLATE_DIRS = (
"/var/www/mysite/templates/admin"
)
I also tried restarting Apache many times. Any suggestions on what I might be doing wrong? Thank you.
It's an issued related to static files rather than templates:
https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production
Use the developer tools on your browser to looks at what requests are being made. Most likely some static files like CSS, etc. are not being served up.

Categories