Running Django Project Locally

76 views
Skip to first unread message

Lekan Wahab

unread,
Aug 24, 2016, 3:25:52 AM8/24/16
to django...@googlegroups.com
Good morning,
I was recently given  a django project to manage at work.
However, i noticed the project has neither a django-admin.py or a manage.py file.
Is that normal?
If it is, how do i run the project on my local machine for testing purposes?

The file structure is something like this:
Project Name
app1
app2
app3
app4
app5
models.py
forms.py
__init__.py
urls.py
views.py
admin.py


Each app contains the following:
models.py
forms.py
__init__.py
urls.py
views.py
admin.py

Asad Jibran Ahmed

unread,
Aug 24, 2016, 3:31:01 AM8/24/16
to Django users
Hi,
 It's definitely weird to not have a manage.py since all new Django projects should have it by default. But the manage.py file is pretty simple, and you can just paste this inside a new manage.py:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os
.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")

   
from django.core.management import execute_from_command_line

    execute_from_command_line
(sys.argv)


Hope that helps.
Regards,
Jibran

Mike Dewhirst

unread,
Aug 24, 2016, 3:49:19 AM8/24/16
to django...@googlegroups.com
On 24/08/2016 5:23 PM, Lekan Wahab wrote:
> Good morning,
> I was recently given  a django project to manage at work.
> However, i noticed the project has neither a django-admin.py or a
> manage.py file.
> Is that normal?
There is usually a manage.py file in the root of the project.
django-admin.py is put in the Python path when Django is installed.
> If it is, how do i run the project on my local machine for testing
> purposes?

* Establish a virtualenv setup (optional but recommended)(separate topic)
* install the same version of Django locally (the file structure you
show indicates a possibly older Django)
* install the same version of the database server locally
* dump the database on the server and load it locally
* mkdir ~/envs
* cd envs
|* ||python django-admin.py startproject projname (or use python3)

At this point you have the bones of the project into which you should be
able to see where to copy the projname directories and files. After
doing so ...

* ~/envs/projname$ python manage.py runserver

This will probably generate errors indicating which 3rd party packages
need to be installed on the local machine. In theory when they are all
installed you should be able to launch the software.
|
Good luck

Mike

>
> The file structure is something like this:
> Project Name
> app1
> app2
> app3
> app4
> app5
> models.py
> forms.py
> __init__.py
> urls.py
> views.py
> admin.py
>
>
> Each app contains the following:
> models.py
> forms.py
> __init__.py
> urls.py
> views.py
> admin.py
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAE6v7ocLOQh_HMxiu29%2Br3wLANJ2wjtesyjb79SXmFXpgb8jgw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAE6v7ocLOQh_HMxiu29%2Br3wLANJ2wjtesyjb79SXmFXpgb8jgw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Lekan Wahab

unread,
Aug 24, 2016, 4:42:57 AM8/24/16
to django...@googlegroups.com
Thanks for getting back to me.
​So, i just figured *manage.py* would also require the *settings.py* which is missing now.
What do i do about that?

Lekan​


To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com <mailto:django-users+unsubscrib...@googlegroups.com>.
To post to this group, send email to django...@googlegroups.com <mailto:django-users@googlegroups.com>.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

Mike Dewhirst

unread,
Aug 24, 2016, 5:23:09 AM8/24/16
to django...@googlegroups.com
On 24/08/2016 6:42 PM, Lekan Wahab wrote:
> Thanks for getting back to me.
> ​So, i just figured *manage.py* would also require the *settings.py*
> which is missing now.
> What do i do about that?

That depends. Is the system currently working?

If so there will be a bunch of settings somewhere and the system will
work on your local machine.

If not, it might be a big ask to do anything quickly. You'll need to do
some research.

In my own projects there are no settings.py files at all. I use a
settings directory and in there I have base.py, local.py, mike_test.py
staging.py and production.py. Each of these imports common settings from
base.py. Here is my local_test.py

from .base import *
SITE_ID = 3
DEBUG = True
TEMPLATE_DEBUG = DEBUG
TEST_RUNNER = 'django.test.runner.DiscoverRunner'

DATABASES = {
'default': {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
"USER": "",
"PASSWORD": "",
"HOST": "",
"PORT": "",
}
}

You can probably find where the settings are being imported from - grep
for ENGINE and that will give you a clue.

Cheers

Mike


>
> Lekan​
>
>
> On Wed, Aug 24, 2016 at 8:48 AM, Mike Dewhirst <mi...@dewhirst.com.au
> <mailto:mi...@dewhirst.com.au>> wrote:
>
> On 24/08/2016 5:23 PM, Lekan Wahab wrote:
>
> Good morning,
> I was recently given  a django project to manage at work.
> it, send an email to django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>
> <mailto:django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>>.
> To post to this group, send email to
> django...@googlegroups.com
> <mailto:django...@googlegroups.com>
> <mailto:django...@googlegroups.com
> <mailto:django...@googlegroups.com>>.
> <https://groups.google.com/group/django-users>.
> <https://groups.google.com/d/msgid/django-users/CAE6v7ocLOQh_HMxiu29%2Br3wLANJ2wjtesyjb79SXmFXpgb8jgw%40mail.gmail.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> <https://groups.google.com/group/django-users>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f61e75cb-12f3-3fe8-e792-a5ce69f473c3%40dewhirst.com.au
> <https://groups.google.com/d/msgid/django-users/f61e75cb-12f3-3fe8-e792-a5ce69f473c3%40dewhirst.com.au>.
>
>
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAE6v7odmC97UYEV0-scQZdoafoa3%3DFkP5dKUA2nJ%2BA7oCEH7Xw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAE6v7odmC97UYEV0-scQZdoafoa3%3DFkP5dKUA2nJ%2BA7oCEH7Xw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Lekan Wahab

unread,
Aug 24, 2016, 6:07:42 AM8/24/16
to django...@googlegroups.com
So,
I have been handed the other part of the project which now contains everything except the manage.py file(which i have created).
Also, the project is quiet old  and some of the dependencies are either no longer being managed or don't exist anymore.(unobase for an example).
As such, i was handed an eggs.zip containing the packages used by the developer.
Now, the question is, how do i install the dependencies from the eggs.py file?
I think its more of a python question than a django issue but i would still appreciate whatever help i can get.



Lekan.


        To post to this group, send email to
        django...@googlegroups.com
        <mailto:django-users@googlegroups.com>
        <mailto:django-users@googlegroups.com
        <mailto:django-users@googlegroups.com>>.

        Visit this group at
        https://groups.google.com/group/django-users



    --     You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it,

    To post to this group, send email to django...@googlegroups.com



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com <mailto:django-users+unsubscrib...@googlegroups.com>.
To post to this group, send email to django...@googlegroups.com <mailto:django-users@googlegroups.com>.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

Hendro Wibowo

unread,
Aug 24, 2016, 7:28:02 AM8/24/16
to Django users
Maybe you can fix it by creating a new Django project in another directory and then copy manage.py (and/or other missing default files) to your current project directory.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com <mailto:django-users+unsub...@googlegroups.com>.
To post to this group, send email to django...@googlegroups.com <mailto:django...@googlegroups.com>.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Michael Macdonald

unread,
Aug 24, 2016, 1:16:30 PM8/24/16
to Django users
Interestingly enough, just this morning, after a couple times being bitten with differences in behavior between use of runserver in development vs. wsgi in production, I've decided to do all development on my local machine under lighttpd.  In the process of (mis?)configuring it now. 

I'm pretty thoroughly convinced that using runserver isn't such a good idea, nor is it particularly useful.  Development I've done under Eclipse and MS VisualStudio in the past did initial local unit testing on a local server; there is ample precedent for this approach.  And, it is best practice to make the development environment as close to the same as the production environment as possible. 

In retrospect, I'm surprised I ever used runserver...

Andreas Kuhne

unread,
Aug 24, 2016, 1:25:34 PM8/24/16
to django...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.

What you get with runserver is automatic reloading - you don't get that running the application behind a webserver. If you run a django app behind anything else except runserver, you will need to restart the server every time you change your code. You will still need to try the application in a production environment, but that is why you have a staging environment (or test). You also need to have a place where QA can test everything (or the product owner) - this environment should be as close to the production environment as possible - so that discrepancies can be found there.

Regards,

Andréas 

Asad Jibran Ahmed

unread,
Aug 24, 2016, 2:32:54 PM8/24/16
to django...@googlegroups.com
One thing I'd add to this is that I could never work without runserver because I tend to use ipdb a lot while debugging any problems. For me the best way to debug is to put import ipdb; ipdb.set_trace() in my code and just start debugging from the command line. Having uwsgi or any other kind of server running my Django code takes away that ability, and I'd be in hell trying to figure out errors without that.

Just my 2 cents.


On Wed, Aug 24, 2016 at 9:24 PM, Andreas Kuhne <andrea...@suitopia.com> wrote:

Michael Macdonald

unread,
Aug 24, 2016, 2:47:27 PM8/24/16
to Django users
Good points.  I tend to merge the roles of developer and QA in my mind when thinking of Django, since it is not my day-job and I'm working alone.  That said, you are correct, when doing something more than quick-hit problem resolution, I'm guessing I'd wind up going back to runserver.  I do still see a need to configure a production-like execution path on one's local development machine.  Even with a QA department (or separate QA environment at any rate), I would think it would save some iterations being able to validate runserver vs. web-server execution prior to handing off.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
What you get with runserver is automatic reloading - you don't get that running the application behind a webserver. If you run a django app behind anything else except runserver, you will need to restart the server every time you change your code. You will still need to try the application in a production environment, but that is why you have a staging environment (or test). You also need to have a place where QA can test everything (or the product owner) - this environment should be as close to the production environment as possible - so that discrepancies can be found there.

Regards,

Andréas 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages