Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django One-To-One and One-To-Many Relations
I am trying to implement the following data model in a Django app: A Project consists of 3 containers: 1) Actionable 2) References 3) Backburner An Entry can be created within a project and needs to be assigned to either of the containers (it cannot remain free-floating). Hence, a Project always contains the three containers, any of which can be empty. An Entry is always in one (and only one) of the containers. However, an Entry can be switched from container to container. Here is my attempt. Is this at all reasonable? class Project(models.Model): project_title = models.CharField() created_date = models.DateTimeField('date created') class References(models.Model): project = models.OneToOneField( Project, on_delete=models.CASCADE, primary_key=True, ) class BackburnerItems(models.Model): project = models.OneToOneField( Project, on_delete=models.CASCADE, primary_key=True, ) class ActionSteps(models.Model): project = models.OneToOneField( Project, on_delete=models.CASCADE, primary_key=True, ) class Entry(models.Model): title = models.CharField(max_length=200) description = models.CharField(max_length=200) action_steps = models.ForeignKey(ActionSteps) references = models.ForeignKey(References) backburner = models.ForeignKey(BackburnerItems) -
Can't get data in edit form
I'm trying to create an edit form for existing users, I have the User model and I associated to it a profile. The problem is that the fields of profile are empty in the rendered html, however when I created a new user I filled these fields, and when I enter to administration I find the fields are filled. models.py from django.db import models from django.contrib.auth.models import User class Profile(models.Model): DEPARTMENT_CHOICES = (('MI', 'Math et info'), ('ST', 'Science et Tech'), ('SM', 'Science de la matiere')) user = models.OneToOneField(User, on_delete=models.CASCADE) teacher = models.BooleanField(default=False) description = models.TextField(blank=True) department = models.CharField(max_length=35, choices=DEPARTMENT_CHOICES, blank=True) picture = models.ImageField(upload_to='profile-images', blank=True) def __str__(self): return self.user.username views.py def profile_view(request): if request.method == 'POST': user_form = EditUserForm(request.POST, instance=request.user) profile_form = EditProfileForm(request.POST, request.FILES, instance=request.user.profile) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() user.save() profile = profile_form.save(commit=False) profile.user = user if 'picture' in request.FILES: profile.picture = request.FILES['picture'] profile.save() return redirect(home) else: user_form = EditUserForm(request.POST or None, instance=request.user) profile_form = EditProfileForm(request.POST or None, request.FILES, instance=request.user) print(request.user.profile.description) return render(request, 'account/profile.html', {'user_form': user_form, 'profile_form': profile_form}) forms.py class EditProfileForm(forms.ModelForm): class Meta: model = Profile fields = ('description', 'department', 'picture', ) class EditUserForm(forms.ModelForm): class Meta: model = User fields = ('username', 'email', ) -
Problema con django y mysql
Unhandled exception in thread started by Estoy intentando levantando levantar mysql en django pero cuando ejecuto la orden $ python manage.py runserver me arroja el siguiente error: Unhandled exception in thread started by Traceback (most recent call last): File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run autoreload.raise_last_exception() File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/Library/Python/2.7/site-packages/django/init.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/Library/Python/2.7/site-packages/django/apps/config.py", line 199, in import_models self.models_module = import_module(models_module_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/Library/Python/2.7/site-packages/django/contrib/auth/models.py", line 4, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "/Library/Python/2.7/site-packages/django/contrib/auth/base_user.py", line 52, in class AbstractBaseUser(models.Model): File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 119, in new new_class.add_to_class('_meta', Options(meta, app_label)) File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 316, in add_to_class value.contribute_to_class(cls, name) File "/Library/Python/2.7/site-packages/django/db/models/options.py", line 214, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/Library/Python/2.7/site-packages/django/db/init.py", line 33, in getattr return getattr(connections[DEFAULT_DB_ALIAS], item) File "/Library/Python/2.7/site-packages/django/db/utils.py", line 211, in getitem backend = load_backend(db['ENGINE']) File "/Library/Python/2.7/site-packages/django/db/utils.py", line 115, in load_backend return import_module('%s.base' % backend_name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 28, in raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb He … -
Travis character can not start any token - django application
I'm trying to integrate Travis CI to my django application and connect it with heorku, this is not the first time I'm doing this, but this is the first time I'm facing this error and I don't understand why is he complaining about python version in travis.yml file, note that I'm using spaces in yml file, rather then tabs. My travis.yml file is: language: python python: - "3.4" # command to install dependencies install: - pip install -r requirements.txt # command to tun tests script: pytest and I'm invoking travis setup heorku command from my terminal, which needs to add heroku api key to my yml file, thus result is showing this found character that cannot start any token while scanning for the next token at line 4 column 1 I have tried this command to travis encrypt $(heroku auth:token) --add deploy.api_key but the same thing is happening, The log form Travis is showing this Worker information hostname: i-14252cec-precise-production-2-worker-org-docker.travisci.net:4291b6eb-e316-4075-a109-f26333325746 version: v2.5.0-8-g19ea9c2 https://github.com/travis-ci/worker/tree/19ea9c20425c78100500c7cc935892b47024922c instance: 9ea3797:travis:ruby startup: 504.511181ms Could not find .travis.yml, using standard configuration. system_info Build system information Build language: ruby Build group: stable Build dist: precise Build id: 181076246 Job id: 181076247 travis-build version: 557e4084f Build image provisioning date and … -
css attributes not changing despite seemingly accurate execution, bootstrap, django
I am trying to style my navbar to remove the small border radius that is default by bootstrap css. As Well I am trying to implement the google font I have chosen. Despite my seemingly perfect execution,nothing is working. I am using django, and although for this that doesn't really matter, it just explains some of the syntax. my links in my HTML file are in the following order: <!-- Loads the path to the static files--> {% load staticfiles %} <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link href="https://googleapis.com/css?family=Satisfy" rel="stylesheet" type="text/css"> <link rel="stylesheet" type="text/css" href="{% static 'music/style.css' %}"> <script src ="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> the HTML attributes I want to manipulate are the following, note the classes <nav class="navbar navbar-inverse"> <div class="container-fluid"> <!--Header--> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mainNavBar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class = "navbar-brand" href="{% url 'music:index' %}">Viberr</a> </div> the div at the top with the class of navbar is the has the border attribute I want to change. The div with the class navbar-brand is the one I want to apply my google font to. Here is my linked css file: body{ background: white url("images/background1.jpg"); } .navbar{ border-radius: 0; } .navbar-brand{ font-family: 'Satisfy', cursive; } As … -
Python Django - ForeignKey Class Choice for Model Field
I want to make it so that i can choose a foreignkey for a field model/class when creating and instance of a model. So something like this: class Posts(models.Model): OwnerType = ( (Accounts, 'User'), (Groups, 'Group'), ) PostTypes = ( ('Text', 'Text'), ('Photo', 'Photo'), ('Audio', 'Audio'), ('Video', 'Video'), ('Link', 'Link'), ) owner = models.ForeignKey(OwnerType, default = 0, related_name = "post_owner") ownerid = models.IntegerField(blank = False, default = 0) owner_type = models.CharField(blank = False, default = '', max_length = 50) title = models.CharField(max_length = 500, default = '') contents = models.CharField(max_length = 500, default = '') attachment = models.CharField(max_length = 500, default = '') attachment_type = models.CharField(max_length = 500, default = '') link = models.CharField(max_length = 500, default = '') post_type = models.CharField(max_length = 20, choices = PostTypes, default = '') status = models.CharField(max_length = 20, default = 'public') # either public, private, or deleted date_created = models.DateField(auto_now_add=True) last_active = models.DateField(auto_now=True) @property def serialize(self): return { 'p_id': self.id, 'ownerid': self.ownerid, 'owner': self.owner.serialize, 'owner_type': self.owner_type, 'title': self.title, 'contents': self.contents, 'attachment': self.attachment, 'attachment_type': self.attachment_type, 'link': self.link, 'post_type': self.post_type, 'status': self.status, 'date_created': self.date_created, 'last_active': self.last_active } class Meta: db_table = "posts" # --- but then i get this error: Traceback (most recent call last): … -
Manage staff permissions in Django
I want to every user who is staff be able to see one certain model of my app as it would be related to it. Instead to overwrite the save function in that model to get every staff user and relate them to the instance of that model through a Forneign Key I want to modify the permissions of the staff users to allow them to see the instances of that especific model in the admin interface. Any clues on how to do it? -
Writing a proper data model in Django
Before you leave this question, please take a look at it, it's not difficult at all for experienced Django programmers. It's just a bit way too messy for people with little experience. I'm trying to write a Django model as I'll explain right now, but as I read further and further in the docs, I find out that I have to take care about too many things and I'm getting really confused with all the considerations I have to bear in mind. I'm trying to write the user model for an organization, in which Users have only one Position. Positions can be either HeadOfDepartment or CommonUser, which both belong to only one Department. Therefore, Departments can have more than one user, but only one HeadOfDepartment, and one or many CommonUsers. Every department must have a HeadOfDepartment, but may have none CommonUser. When I delete a User, It shouldn't delete the HeadOfDepartment Position, which should be left empty (no user in it), nor the Department which it belongs to. However, if the user had a CommonUser position, it should remove it, since that position is not strictly necessary for the department. When I create a Department, it should obligatory have a … -
One Form Multiple Models
I am struggling to find good information on how to display data, or reference data from multiple models on one form. Right now I generate a listview with my servicereports model. In that list view I pick out a few columns to display (Customer, Date, Originator). The customer column is actually filled with primary key references to another model, the customers model. How can I take that pk and use it to reference the actual customer name from another model? -
Djngo Admin login OperationalError at /admin/login/ (1044, "Access denied for user
I'm using Django 1.10 with Python 3.5.2 on the PythonAnywhere web hosting platform and I am trying to login to the Admin site with my my Django superuser called adminuser but I am having this error, OperationalError at /admin/login/ (1044, "Access denied for user adminuser What can be the problem? -
Django: sum values in for loop
i want to sum of the orders price in formset. how to sum int(food.price) * int(f.order_count) ? for f in formset: food = Food.objects.get( se_date__startswith = datetime.date(int(year), int(month), int(day)), food_name=f.order_name) print sum(int(food.price) * int(f.order_count)) -
django app keeps migrating without taking effect [heroku]
I have been trying to fix this for the past three days and I keep failing. So, I have a simple app, that just has models.py and admin.py for now. When I migrate locally, everything is totally fine, when I run createsuperuser, I can create a user that I can use to login into the admin dashboard. However, when I do the same on heroku. It doesn't work.. The bad news is, those tables were never created, because this is what happens when I run migrate again: I literally have no idea what's wrong with it, so any help would be appreciated. Thanks in advance :) -
Django custom permissions does not added
I have a class called TypedItem class TypedItem(BaseModel): type = models.CharField(choices=['g', 'k'], max_length=1) class Meta(BaseModel.Meta): permissions = [ ('change_type', 'Can change type') ] I called python manage.py makemigrations and it creates a migration; migrations.CreateModel( name='TypedItem', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('type', models.CharField(choices=['g', 'k'], default='g', max_length=1)), ], options={ 'permissions': [('change_type', 'Can change type')], 'abstract': False, }, bases=(dirtyfields.dirtyfields.DirtyFieldsMixin, models.Model), ), But I can't see my custom permission in database after I called python manage.py migrate. Am I have to do something extra? Thx. -
AUTH_USER_MODEL not getting configured properly for Django Oscar Sanbox
I am trying to run the sandbox site (django-oscar) (which I've done successfully ). I am also trying enable the user app (which is disabled by default) so that my model gets migrated. So far I've followed the docs religiously and I have done the following: INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', 'django.contrib.flatpages', 'django.contrib.staticfiles', 'django.contrib.sitemaps', 'django_extensions', # Debug toolbar + extensions 'debug_toolbar', 'apps.gateway', # For allowing dashboard access 'widget_tweaks', ] + oscar.get_core_apps(['apps.user'])+ oscar.get_core_apps(['apps.user']) #Added this line to the settings.py file AUTH_USER_MODEL = 'user.ExtendedUserModel' #Now I am trying to point to this as my auth model But no matter what I try, I keep getting the following error: ImproperlyConfigured: AUTH_USER_MODEL refers to model 'user.ExtendedUserModel' that has not been installed Anyone has an insight on this? What am I missing? P.S. - I am new to django-oscar -
Django Row-level permission, passing record and permission
In order to create a row-level permission system, I have created ContentInstance model that keeps track of record_id and model. I know that there are 3rd party apps like guardian for row-level permission, but I would like to implement one for myself. So, ideally, I want to say something like: class EmployeeMain(View): template_name = 'main.html' @method_decorator(login_required) @method_decorator(user_passes_test(user_has_permission('view', 'employee', kwargs['pk'])) def dispatch(self, *args, **kwargs): return super(EmployeeMain, self).dispatch(*args, **kwargs) the kwargs['pk'] refers to url's captured argument: url(r'employee/(?P<pk>\d+)/$', RFIMain.as_view(), name = "employee_main"), So, given the model (employee), the record in the model (kwargs['pk']), the user, and the permission privileges, the user_has_permission function returns true if the user has model-wide permission or is given the permission for that specific item in that model. Otherwise, it returns False. I have implemented the user_has_permission function and it should work. The problematic part is how to pass url's captured argument and the model to the decorator. Any ideas? -
Adding image upload to the plugin edit dialog in DajngoCMS
I am new to Django CMS and am trying to build a plugin for a hero section (something like this). I want to enable content managers to change the image of the hero section. I managed to add a text input to put the image's URL by using CharField in the model but looking of a way to allow image upload. This is the current state for reference: -
Django Haystack can't index datetime field
I am using django Haystack with ElasticSearch backend. In my Model I have a DateTimeField which is creating problems while rebuilding_indexes. My Model is like this: class MyModel(models.Model): action = models.DateTimeField() My Index Class is like: Class MyModelIndex(indexes.SearchIndex, indexes.Indexable): action_time = indexes.DateTimeField(null=True, model_attr="action") The value i got in shell for the particular instance which is creating problem is obj = MyModel.objects.get(id=1) obj.action Out[56]: datetime.datetime(2016, 6, 21, 14, 6, 37, 430691, tzinfo=<UTC>) # result or value of action field And the error I am getting while creating indexes is if not language_code_re.search(lang_code): TypeError: expected string or buffer I tried to return strftime from indexes from prepare field , but it also doesn't work def prepare_action_time(self, obj): return obj.action.strftime('%Y-%m-%dT%H:%M:%SZ') if obj.action else None but it works if I return unicode representation of the datetime Value like def prepare_action_time(self, obj): return unicode(obj.action) if obj.action else None or without using use_template=False in my searchindex I am able to index the documents or the objects But I am unable to get where the actual problem is. Help will be appreciated -
Django Faking Required Fields
I'd like to know if there's any to way to make a nullable (null=True) field be required when creating models (or saving)? As a superuser, I'd like to be able to leave certain fields with null while other staff members won't be able to. Is there any way to do something like that? Thanks in advance. -
I need to automate adding content onto Wordpress site
I want to automate putting information from various web sites into an HTML email sent to colleagues internally. So pulling story headlines from our news site or other news sites and links, with the layout pre-done in Wordpress. I know Wordpress is PHP and not python or django -- saw this asked. I was thinking have Wordpress pull XML tagged info that is collected with selenium python scraper. And maybe some django so the scraper can clean up the info before it's pulled in to Wordpress template. For the life of me tho I can't find a question and answer that many newsletters need -- that is how to automate pulling in of content into a preexisting template on Wordpress. Wordpress can import by tags if in proper categories I'm not sure how to link all this with scraping and original content. -
Can't update value of IntegerField of Django 1.8
class UserProfile(models.Model): user = models.OneToOneField(User) how_much_new_notifications = models.IntegerField(null=True,blank=True,default=0) User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0]) In views.py function which is 100% called and whom is present whom.profile.how_much_new_notifications += 1 whom.save() Whatever, how_much_new_notifications is still equal zero and not incriminated , despite everything else is correct Also tried something like this: if whom.profile.how_much_new_notifications == None: whom.profile.how_much_new_notifications = 1 else: varible_number_of_notifications = int( whom.profile.how_much_new_notifications) whom.profile.how_much_new_notifications = varible_number_of_notifications + 1 Get no errors in log, is there any reason why this code wouldn't work, or should I search for issues in other places? -
django.db.utils.OperationalError: unable to open database file
When I run python manage.py runserver I get this error File "/usr/local/lib/python2.7/dist-packages/Django-1.10.1-py2.7.egg/django/db/backends/sqlite3/base.py", line 209, in get_new_connection conn = Database.connect(**conn_params) django.db.utils.OperationalError: unable to open database file my settings.py: DATABASES = { 'default': dj_database_url.config( default="sqlite:///{}".format( os.path.join(BASE_DIR, 'db/db.sqlite3') ) ) } -
Pixi.js can't load images because Django "can't find them"
I am sorry if the question seems a little bit confusing, but I couldn't find a better way to phrase it. I am not very experienced in web development, and as I was trying to develop a game I run into an error I can't seem to fix. I started developing by starting with the front-end, and when I had my game running I tried to move to the back-end, so I can implement leaderboards and users. I am using Pixi.js, a javascript framework to help me developing the game. I use some images in the game and Pixi has a loader, which was working ok: PIXI.loader .add([ "images/quarter.png", "images/c_quarter.png", "images/clef.png", "images/heart.png" ]) .on("progress", loadProgressHandler) .load(init); When I moved to Django, I had to load my javascript using static files. However, images won't load using the Pixi loader, and I get the following error in my developer console: quarter.png:1 GET http://127.0.0.1:8000/game/images/quarter.png 404 (Not Found) And this is what was happening in my server terminal: Not Found: /game/images/quarter.png [04/Dec/2016 13:38:49] "GET /game/images/quarter.png HTTP/1.1" 404 2146 Not Found: /game/images/c_quarter.png Not Found: /game/images/heart.png Not Found: /game/images/clef.png [04/Dec/2016 13:38:49] "GET /game/images/c_quarter.png HTTP/1.1" 404 2152 [04/Dec/2016 13:38:49] "GET /game/images/clef.png HTTP/1.1" 404 2137 [04/Dec/2016 13:38:49] "GET … -
Django CDN with Nginx and uWSGI
I having difficulty serving static files with Django 1.10, uWSGI and Nginx. I have an index.html file, which contains CDN's. The Django documentation, which is here says to "transfer the static files to the storage provider or CDN." What does that mean, "transfer to the CDN"? Isn't the CDN where you get files from? settings.py contains, STATIC_URL = '/static/' STATIC_ROOT = 'nonAppBoundStaticDirectory' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] Running $ python manage.py collectstatic does this place all CDN's in my directory 'nonAppBoundStaticDirectory'? If so then how do i use that in the template? Excerpt from index.html <!-- Bootstrap --> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css"> Excerpy from /etc/nginx/nginx.conf server { # the port your site will be served on listen 80; # the domain name it will serve for server_name example.com; # substitute your machine's IP address or FQDN charset utf-8; #Max upload size client_max_body_size 75M; # adjust to taste # Django media location /media { alias /home/ofey/djangoForum/fileuploader/uploaded_files; # your Django project's media files } location /static { alias /home/ofey/djangoForum/noAppBoundStaticDirectory; # your Django project's static files } ........ Thanks, -
Django-endless-pagination: apply javascript to whole html after "show more"?
views.py class PortfolioListView(AjaxListView): model = Portfolio context_object_name = "portfolios" template_name = "portfolios/portfolio_list.html" page_template = 'portfolios/portfolio_list_page.html' portfolio_list.html {% extends "skeleton/base.html" %} {% load el_pagination_tags %} {% block content %} <div class="test-class"> hi-1 </div> <section> <div class="container"> <div class="row"> <div class="col-md-offset-1 col-md-10"> {% include page_template %} </div> </div> </div> </section> {% endblock %} {% block custom_js %} <script src="{% static 'el-pagination/js/el-pagination.js' %}"></script> <script>$.endlessPaginate({});</script> <script type="text/javascript"> $(document).ready(function(){ $(".test-class").click(function(){ alert("ji"); }); }); </script> {% endblock %} portfolio_list_page.html <div> {% lazy_paginate portfolios %} <div class="test-class"> hi-2 </div> <div class="test-class"> hi-3 </div> {% show_more %} </div> When I load portfolio_list.html page and click hi-1, it shows alert. But when I click show more and click hi-2 or hi-3, it doesn't show alert. I want to show alert even I clicked hi-2 or hi-3. How can I implement this? p.s Actually, this is a kinda very simple code for showing clearly what I want to do. What I eventually want to do is to execute whole javascripts code(e.g _owl_carousel(), _flexslider(), _popover(), _lightbox(), _mixitup(),, etc) after loading portfolio_list_page so that this whole javascript function also can be applied to newly loaded page -
python ./store/manage.py runserver
python ./store/manage.py runserver when i ran this i got error like this $ python ./store/manage.py runserver Unhandled exception in thread started by Traceback (most recent call last): File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\core\management\commands\runserver.py", line 113, in inner_run autoreload.raise_last_exception() File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\utils\autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\apps\registry.py", line 85, in populate app_config = AppConfig.create(entry) File "C:\Python27\lib\site-packages\django-1.10.4-py2.7.egg\django\apps\config.py", line 90, in create module = import_module(entry) File "C:\Python27\lib\importlib__init__.py", line 37, in import_module import(name) ImportError: No module named polls