Running Django 1.3 on Heroku - django

I'm trying to figure out if its possible to get django 1.3 running on heroku. I have been going off of their tutorial which assumes the user is using the latest version (1.4) of django. If I follow the tutorial, with the exception of explicitly using Django==1.3 instead of the most recent django version, I get an error when I run django-admin.py startproject hellodjango . (note the dot)
Error:
File "/home/my_dir/.virtualenvs/hellodjango/local/lib/python2.7/site-packages/django/utils/importlib.py", line 28, in import_module
raise TypeError("relative imports require the 'package' argument")
TypeError: relative imports require the 'package' argument
It still creates the project and the welcome page comes up on http://127.0.0.1:8000/. If I keep going with the tutorial and push it to heroku I get
ImportError at /
No module named hellodjango.urls
Seems like there is some mismatch between file structure between the tutorial and django 1.3.
Instructions on how to install Django 1.3 would be very helpful.

This '.' option don't work for me even with Django 1.4 i get same error as you did. So i ignored the dot:
django-admin.py startproject hellodjango
Then i moved all files from hellodjango folder to it's parent folder (that's what Heroku need) and deleted the hellodjango folder.
Followed all steps so i could get the app running on heroku but i got same error as you again, "No module named hellodjango.urls". I solved this removing this hellodjango part from settings.py as i changed the files to a new path so settings.py reflect that change now and everything is fine.

The '.' at the end of the ./manage.py startproject myproject . means start a project "in the current directory"(This feature was added in djago 1.4). In django 1.4 instead of importing from myproject import myapp, you just import yourapp directly. Your apps are not longer tied to your projects.
I found this article online that may help you solve your problem:
http://bitkickers.blogspot.com/2012/04/djangoheroku-quickstart-for-existing.html

Related

Created a brand new Django Project, attempting to run the server generates an Improperly Configured Error

I have been working on a Django Project for a bit, until I took a break. One month later I dug back in to the project and went to run the server. I received an error:
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I figured I must have tweaked something by accident. So I created a brand new Django Project (using a virtual environment), and just went to test the server. I received the same error. I tried the python manage.py shell solution listed in another answers but to no avail.
If it helps I'm on Linux with Django version 2.1.5 and Python 3.6.
Edit:
If anyone encounters something similar I found using python3 manage.py runserver works in place of using django-admin. Per Greg's answer below, I did begin to receive a new error ModuleNotFoundError: No Module named "mysite" exists. I will continue to search for an answer on that front.
Going off of the comments here.
If "env | grep DJANGO_SETTINGS_MODULE" returns empty, it means you have to set an environment variable stating where your settings.py file is located.
This can be done by doing the following:
export DJANGO_SETTINGS_MODULE=mysite.settings
Be sure to replace "mysite" with the name of your app!

Can't runserver, ModuleNotFoundError[Django]

I'm trying to work with django, but I can't runserver it shows an error like this
"ModuleNotFoundError: No module named 'music.apps. MusicConfig'; 'music.apps' is not a package"
Note: I'm using python3.
Probably your music/apps directory doesn't contain __init__.py file. Create and empty one and apps will become a package

ImportError: No module named allauth

I have installed django-allauth for using social accounts in my django app but every time I try
manage.py syncdb
It gives me an error
ImportError: No module named allauth
I tried to add even
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
to
manage.py
but its still not working.I am unable to debug about how to add path to allauth to include it?
go to the root of the folder where you have your virtual environment and type:
source bin/activate

How can I satisfy a django.contrib.markup.templatetags.markup import restructuredtext in django 1.6?

Wondering which restructured package most of you use in django 1.5+?
from django.contrib.markup.templatetags.markup import restructuredtext
Returns:
ImportError ...
No module named markup.templatetags.markup
https://docs.djangoproject.com/en/1.6/releases/1.5-alpha-1/#django-utils-markup
Yes the django.utils.markup was deprecated in 1.5 and removed in 1.6. The Python implementation of the reStructuredText markup lives in the docutils package. That is the implementation that Django <= 1.5 used.
The easiest way to install docutils is using pip:
pip install docutils
You can find the old django.utils.markup implementation in the 1.5.x branch on Djangos github repo:
https://github.com/django/django/blob/stable/1.5.x/django/contrib/markup/templatetags/markup.py#L76
This is an addon to the answer by #jbub:
When you have an old Django application and you want to continue using markup, follow these steps:
Delete django.contrib.markup from INSTALLED_APPS (in the file settings.py
Add a directory templatetags to your application
Copy the file markup.py from https://github.com/django/django/blob/stable/1.5.x/django/contrib/markup/templatetags/markup.py#L76 to templatetags
touch a file __init__.py in the templatetags directoy
Start over your webserver and see it working again.
Note that this procedure keeps your old application working. However, the deprecation of django.contrib.markup came for a reason: There were security concerns over possible cross-site scripting attacks using markdown. You are on your own to deal with this problem.

Django + Virtualenv: manage.py commands fail with ImportError of project name

This is blowing my mind because it's probably an easy solution, but I can't figure out what could be causing this.
So I have a new dev box and am setting everything up. I installed virtualenv, created a new environment for my project under ~/.virtualenvs/projectname
Then, I cloned my project from github into my projects directory. Nothing fancy here. There are no .pyc files sitting around so it's a clean slate of code.
Then, I activated my virtualenv and installed Django via pip. All looks good so far.
Then, I run python manage.py syncdb within my project dir. This is where I get confused:
ImportError: No module named projectname
So I figured I may have had some references of projectname within my code. So I grep (ack, actually) through my code base and I find nothing of the sorts.
So now I'm at a loss, given this environment why am I getting an ImportError on a module named projectname that isn't referenced anywhere in my code?
I look forward to a solution .. thanks guys!
Is projectname exactly (modulo suffix) the name of the directory the project is in? Wild guess, but I know Django does some things with the current directory…
Also, what is trying to import projectname? Do you get a traceback? If not, try running with py manage.py --traceback syncdb and see what happens.