Urls.py Question

34 views
Skip to first unread message

G Z

unread,
May 6, 2014, 1:50:25 AM5/6/14
to django...@googlegroups.com

project name = provisioning app name = vmware

In my projects urls.py I have the following. I assume I set the new url link customers to myapp.urls because im watching a youtube video and thats what he did.

from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^customers/', include(vmware.urls)),
)

In my vmware directory I have the urls.py file as the video had me design. To which I have the following code:

from django.conf.urls import patterns, include, url
from django.view.generic import ListView
from vmware.models import Customer

urlpatterns = patterns('',
                      url(r'^customers/', ListView.as_view(
                                queryset=Customer.objects.all().order_by"-id")[:100],
                                template_name="VMS.html")),
)

Now when I syncdb and runserver I get no erros. But when I try to resolve the page I get the following. It says vmware is not defined but it is defined in my installed apps.

<code>Environment:
Request Method: GET Request URL: http://23.239.206.142:8001/admin/
Django Version: 1.6.4 Python Version: 2.7.3 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'vmware') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 101. resolver_match = resolver.resolve(request.path_info) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve 337. for pattern in self.url_patterns: File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in url_patterns 365. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in urlconf_module 360. self._urlconf_module = import_module(self.urlconf_name) File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module 40. import(name) File "/root/djangoprojects/provisioning/provisioning/urls.py" in <module> 12. url(r'^customers/', include(vmware.urls)),
Exception Type: NameError at /admin/ Exception Value: name 'vmware' is not defined</code>

Rafael E. Ferrero

unread,
May 6, 2014, 7:08:06 AM5/6/14
to django...@googlegroups.com
What version of django do you have runing?, do you define an admin for vmware?

--
Rafael E. Ferrero


--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d3990a55-76d9-4b4a-81d0-903a00c021b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

G Z

unread,
May 6, 2014, 1:22:36 PM5/6/14
to django...@googlegroups.com
I'm running 1.6.4

yes vmware is in my installed apps i used from . import vmware
if I dont try to link my appurls to project urls and just use admin site all my stuff works correctly its just when i try to add vmare

project.urls


from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()
from . import vmware

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'provisioning.views.home', name='home$
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^customers/', include(vmware.urls)),
)


app.urls


from django.conf.urls import patterns, include, url
from django.view.generic import ListView
from vmware.models import Customer

urlpatterns = patterns('',
                      url(r'^customers/', ListView.as_$
                                queryset=Customer.obje$
                                template_name="VMS.htm$
)


settings.py


INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'vmware',
)


INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'vmware',
)


directory structure provisioning is the project vmware is the app.
drwxr-xr-x 4 root root 4096 May  5 20:12 .
drwxr-xr-x 3 root root 4096 May  5 19:09 ..
-rw-r--r-- 1 root root  255 May  5 19:09 manage.py
drwxr-xr-x 2 root root 4096 May  6 11:15 provisioning
drwxr-xr-x 3 root root 4096 May  6 11:15 vmware



models.py

from django.db import models

# Create your models here.

class Customer(models.Model):
    NAME = models.CharField(max_length=200)
    WEBSITE = models.CharField(max_length=200)
    PHONE = models.CharField(max_length=200)
    EMAIL = models.CharField(max_length=200)
    ADDRESS = models.CharField(max_length=200)
    VMIDS = models.CharField(max_length=200)

    def __unicode__(self):
        return self.NAME
#               return self.NAME

class Vms(models.Model):
    VMID  = models.CharField(max_length=200)
    VMNAME = models.CharField(max_length=200)
    VMSTATUS = models.CharField(max_length=200)
    CUSTOMERID = models.ForeignKey(Customer)

class Vmspecs(models.Model):
    CPUS =  models.CharField(max_length=200)
    CORES =  models.CharField(max_length=200)
    MEMORY =  models.CharField(max_length=200)
    HDSPACE =  models.CharField(max_length=200)
    OS =  models.CharField(max_length=200)
    UPTIME = models.CharField(max_length=200)
    VMID = models.ForeignKey(Vms)

  #  choice_text = models.CharField(max_length=200)



James Schneider

unread,
May 6, 2014, 9:15:27 PM5/6/14
to django...@googlegroups.com
You need to quote the argument being passed to include():

include('vmware.urls')

There might be other things going on, but I'm on my phone and it's hard to follow.

-James
--
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 http://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages