how to run django-simple-blog? - python

How to run Django-simple-blog? I tried to install django-simple-blog but could not find the manage.py file to run it. Can I get a solution or another simple blog?

Django has a concept of apps and a concept of projects. A project will have a manage.py file like you mention, and will also have a settings.py file that declares all of the apps that the project uses.
django-simple-blog is an app, meaning you install it within an existing project. After this explaination, the rest of the steps found here should be easier to follow: https://github.com/drager/django-simple-blog/blob/master/README.rst
The remaining steps are to:
Add 'simpleblog' to INSTALLED_APPS in your settings.py file
run the command python manage.py migrate from your project root
include 'simpleblog.urls' into any of your urls.py file

Related

How do I reinstall the db.sqlite3 file in django

I am a beginner with django and I accidentally deleted the db.sqlite3 file in my django project.
I made a new django project but the db.sqlite3 file was not in it. I also uninstalled and reinstalled django and project but the db.sqlite3 file still wasn't there in the project. What do I do.
Thank you.
I am a beginner with django and I accidentally deleted the db.sqlite3 file in my django project. I made a new django project but the db.sqlite3 file was not in it. I also uninstalled and reinstalled django and project but the db.sqlite3 file still wasn't there in the project. What do I do. Thank you.
Delete everything except init.py file from migration folder in all django apps
Make changes in your models (models.py).
Run the command python manage.py makemigrations or python3 manage.py makemigrations
Then run the command python manage.py migrate.

Reinstalling Django App - Data tables not re-created

I am trying to reinstall one of my apps on my project site. These are the steps that I have followed to do so:
Removing the name of the installed app from settings.py
Manually deleting the app folder from the project folder
Manually removing the data tables from PostgreSQL
Copying the app folder back into the project folder; making sure that all files, except __init__.py is removed.
Run python manage.py sqlmigrate app_name 0001
Run python manage.py makemigrations app_name
Run python manage.py migrate app_name
Run python manage.py makemigrations
Run python manage.py migrate
However, after all these steps the message I am getting is that there are "no changes detected" and the data tables have not been recreated in the database, PostgreSQL.
Am I missing some additional steps?
I think I might have managed to solve the problem. The command, python manage.py sqlmigrate app_name 0001, produces the SQL statements required for the table creation. Thus, I copied and paste the output into the PostgreSQL console and got the tables created. It seems to work for now, but I am not sure if there will be repercussions later.

Adding a second project to a Django project

I'm new to Django. I'm using Django with Eclipse. I've created a Django project using Eclipse (called "Django_Test_Project"). I've also created a PyDev project outside of Eclipse, using the command line (called "polls"). It has models.py, views.py, and tests.py.
I created "polls" using the following command:
manage.py startapp polls
I want use Eclipse to add "polls" as a second project to "Django_Test_Project". How do I do that with a project that was created outside of Eclipse? Eclipse doesn't recognize "polls" as a project, probably because the project files are missing in "polls".
Any help is appreciated. Thanks.
You are working on the Django tutorial, right? First of all, your terminology is not correct. You confuse a project with an application or app for short. It's no surprise that Eclipse doesn't recognize polls as a project, because it's not a project but an app.
In Django 1.4.1, the standard structure for a project called mysite is this:
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
Your polls app should go in the same directory where the file manage.py is located:
mysite/
manage.py
polls/
__init__.py
models.py
tests.py
views.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
You can just move the polls directory into the mysite directory using the Windows Explorer, Finder, Terminal etc. (depends on which OS you are running on). After refreshing the project view in Eclipse, your polls app should show up. In any case, you should read the Django tutorial more carefully as it basically answers your question already.
Additionally, take a look at this thread that explains the difference between projects and apps in a bit more detail.

Deploying Django application on Webfaction

This is the first time I am trying to deploy my django project (myproject) on Webfaction.
My project dir-structure is as follows:
In webapps/django: myproject.wsgi, myproject
settings.py is at myproject/src/myproject/
Under such circumstances, how should I define DJANGO_SETTINGS_MODULE in myproject.wsgi?
For the default installation by webfaction, it is defined as myproject.settings. Should I be defining DJANGO_SETTINGS_MODULE as myproject.src.myproject.settings?
When you setup a Django project on webfaction, you get a file structure like so:
~ (your home directory)
+webapps
+some_project_name
+myproject
-standard django files
-settings.py
-app_directory
+apache2
+bin
-start
-stop
-restart
-other dirs
-bin
-lib
-myproject.wsgi
-some_project2
-symlink_to_static_files
If you are building your project under "myproject", you should not have to modify the wsgi file to get started- just change to the apache2/bin directory and run ./start and you're good to go!
If you change the wsgi file you'll need to run ./stop then ./start to activate the changes.
If the path you listed isn't working, it may be worth trying to create a generic django project and just puaste your project right over 'myproject'
It seems like your service provider has already given you some helpful instructions:
http://docs.webfaction.com/software/django/getting-started.html

Exist a diference in use django-admin.py or manage.py

I'm learning something about Django.In some tutorials that i've read is used django-admin.py for execute commands like " syncdb, startapp and startproject", in the others tutorials is used manage.py, So exist any important diference between use django-admin.py or manage.py ?
See: django-admin.py and manage.py in Django documentation
manage.py is a wrapper around django-admin.py automatically created in each Django project which puts your project's package on sys.path and sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project's settings.py file.
So, I think is more comfortable to use manage.py when you're working on a Django project.
manage.py is a file that excists in a project environment and is created after starting a project. It's purpose is to control project commands. Django-admin.py is a script to start a project ( you can put it anyhwhere, or shortcut it via .bash or .profile )
manage.py is django-admin fitted in your project: it uses settings.py in your project dir

Categories