Thursday, April 11, 2013

Re: Custom Commands?

So, you have a management/commands structure in each app of your project and not in the main "app" (or whatever that thing is called).  Here is the structure of my whole project thus far (I had just shown the part that I thought was important).  As you can see I already had an app and the app is included in the INSTALLED_APPS of settings.py:

│   manage.py

├───mysite
│   │   settings.py
│   │   settings.pyc
│   │   urls.py
│   │   urls.pyc
│   │   wsgi.py
│   │   wsgi.pyc
│   │   __init__.py
│   │   __init__.pyc
│   │
│   └───management
│       │   __init__.py
│       │
│       └───commands
│               x.py
│               __init__.py

├───mytemplates
│   ├───admin
│   │       base_site.html
│   │       index.html
│   │
│   └───polls
│           detail.html
│           index.html
│           results.html

└───polls
        admin.py
        admin.pyc
        models.py
        models.pyc
        tests.py
        urls.py
        urls.pyc
        views.py
        views.pyc
        __init__.py
        __init__.pyc



On Wed, Apr 10, 2013 at 11:54 PM, Andrey Kostakov <bps@dzen.ws> wrote:
For first step you need create application, "manage.py startapp myapp".
'management' folder should be located in your application folder. And
don't forget add application in INSTALLED_APPS in your settings.py
(INSTALLED_APPS = ('myapp', ))

On Thu, Apr 11, 2013 at 4:52 AM, Mark Lybrand <mlybrand@gmail.com> wrote:
> I am at a loss how to get custom commands working in my Django project.
>
> I am on Windows 7, running Python 2.7.3, Django 1.4.5.  When I try to make
> my "hello world" command, I get an unknown command error.
>
> I have the following structure:
>
> │   manage.py
> │
> ├───mysite
> │   │   settings.py
> │   │   settings.pyc
> │   │   urls.py
> │   │   urls.pyc
> │   │   wsgi.py
> │   │   wsgi.pyc
> │   │   __init__.py
> │   │   __init__.pyc
> │   │
> │   └───management
> │       │   __init__.py
> │       │
> │       └───commands
> │               x.py
> │               __init__.py
>
>
> And this is the code of my command:
>
> from optparse import make_option
> from django.core.management.base import BaseCommand, CommandError
>
> class Command(BaseCommand):
>     option_list = BaseCommand.option_list + (
>         make_option('--long', '-l', dest='long',
>             help='Help for the long options'),
>     )
>     help = 'Help text goes here'
>
>     def handle(self, **options):
>          print "This is a command"
>
> When I run
>
> python manage.py x
>
> I get:
>
> Unknown command: 'x'
> Type 'manage.py help' for usage.
>
> Where should begin looking to troubleshoot this issue?
>
> Thanks in advance...
>
> Mark :)
>
>
> --
> 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-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Best regards,
Andrey Kostakov
Email/Gtalk: bps@dzen.ws

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.





--
Mark :)

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate