Django admin page is missing CSS - python

I am actually following a youtube tutorial for learning Django and admin site is not showing properly.
The admin tab in the video looks like this:
My admin tab however looks like this:
An answer in stack overflow suggested to put DEBUG = True in settings.py file. But it is already set to that in my case.

You've probably set static files' location the wrong way. Sending settings.py is needed for any further help.
You can check this document for default values.

It would be better to start a simple project using the instructions provided in this documentation Django - Introduction tutorial
Initially, you can also try the following instructions to check it.
At first, install django (latest version) using the following command
python -m pip install django
Then, open a folder in which you would like to create a django project, and open the terminal in that folder, then paste the following code
django-admin startproject MyProject
Copy and paste the following two commands one-by-one,
py manage.py makemigrations
py manage.py migrate
After that, create a admin user by providing the e-mail, username and password through the following command as follows,
py manage.py createsuperuser
Now, copy and paste the link you get in the browser along with 'admin/', which will direct you to the admin login page as specified in the documentation

Related

Django admin panel lags and doesn't show anything

Today I've launched my Django project and saw a really weird behavior of Django admin panel. At the first sight, everything looks OK but as soon as I click on any model to view, I can't see anything. The most strange thing is that I've got no weird commits that could damage the contents of admin panel recently. The only commit could do that is updating Django to 3.1 version. I've already tried reinstalling Django and installing older versions but nothing works.
Here is the typical admin panel homepage
Here is what happens when I click on models
I really need to know how to fix it as well as both me and my friend have this issue and we can't deal with it.
First thing that you should check for this error is to see if you are calling:
admin.site.register(<model-name>)
and not
admin.register(<model-name>)
if this is not the case then try running the migrations again
python manage.py makemigrations
python manage.py migrate
Finally, make sure your admin.py file with the code is actually inside the directory of the app (i.e. the same directory with your models.py that defines MyModel).

I want to Create my first URL using the command prompt

I have Django installed,but I was trying to create my first URL and I typed the following using the command prompt
"cd myproject" then again I typed "manage.py runserver 127.0.0.1:8000" And I got the following output:
"System check identified no issues<0 silenced>
you have 17 unapplied migration. Your project may not work properly until you apply the migrations for app: admin,auth,contenttypes,sessions."
Please what do I do to fix this problem so that my project can work properly?
Note that: I am new in using Python and Django
You already have an advice to read the tutorial but in case you want to continue on your own (before next trouble), you need to run this in console in order to apply migrations:
python manage.py migrate
Read more about migrations and this command here.
You need to migrate the database first. But it's not error actually. It's just a warning. If you don't want to migrate(create DB tables) just ignore it. And you can still browse 127.0.0.1:8000
Migration command
python manage.py migrate
Read Django documentation very carefully. Django Official Documentation

Why i am not seeing a .py file but something else (trying to create Django project)

So I got advice in another question and they started talking about paths and .exe and that I should not put my projects in the scripts. So I added
C:python27\scripts to my path and nothing seemed to change except when I created a new project, and went into the GUI to look for the folder and found it, it just says Manage instead of manage.py. It says its a python folder.
I then took ..\scripts out of the path and created the project again and still got the same thing.
Whenever I did it the first time without changing anything, I did see a manage.py file.
So the tutorial I am working that introduces me to Django asked me to open the manage.py file, and when I try to of course it tells me it can't open the file because it does exist. So what do I do?
If I'm understanding you correctly, you're simply trying to create a django project. Since you didn't mention which tutorial you're using, I'll link this resource and recommend following it page for page. It's a great walk-through for learning how to create apps and it's broken into sessions you can do over a period of time:
To answer your question: when you create a django project with django-admin startproject mysite it will install the manage.py into the mysite directory. If that doesn't answer your question, try describing the precise steps you're taking to create a Django project including all commands you're using (if any).
It's also helpful to know if you're using a virtual environment.

Configuring an Existing Django Project on Pycharm

I´m starting to use Django with Pycharm IDE and have succesfully configured my first project.
However, I tried to add a new existing project to Pycharm and when trying to change the Run Configuration to use the manage.py of my secondProject(GuatepediaLocal), I don´t get an option to select it on the dropdown menu. When I try to run the project, it keeps running the PollSite manage.py runserver and not GuatepediaLocal´s manage.py runserver
Can anyone help me to solve this issue and configure an already existing Django Project on pycharm?
After some research I found that on the settings window of Pycharm I must add Django support to my project
That enabled the project on the dropdown menu. After that, I just added on the enviroment variables the correct path to my project´s settings.py.
Hope this helps someone someday :)
Open edit configuration wizard.
Menu > Run > Edit Configuration
Add new configuration by selecting the Django server from the left top button (button look like + sign). Look like below. Plus sign top left.
If you don't configure the Django setting. It will show you the fix button to fix the Django Setting. Django Setting looks like this. You can manually set these setting by navigating like this.
File > Settings > Language and Framework > Django
Django Setting wizard looks like this.
set the project path, manage.py file and settings.py file.

How to let user login on Mezzanine tutorial website?

I just installed Mezzanine on my linux server. Following the tutorial, with the command set
mezzanine-project project_name
cd project_name
python manage.py createdb --noinput
python manage.py runserver
Now I have the first simple site working now.
In the setting, there is a check box about
"Accounts required for commenting: If True, users must log in to comment"
But I can't see any log in function provided on the tutorial website.
Should we just handcraft the create account/ log in function? Or is there a better way to do that? Thanks.
You need to enable the mezzanine.accounts app which has provides all the login functionality.
This is entirely covered in the documentation:
http://mezzanine.jupo.org/docs/user-accounts.html

Categories