Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Python-social-auth: do not reassociate existing users
I'm using python-social-auth to allow users to login via SAML; everything's working correctly, except for the fact that if a logged-in user opens the SAML login page and logs in again as a different user, they'll get an association with both of the SAML users, rather than switch login. I understand the purpose behind this (since it's what you can normally do to associate the user with different auth services) but in this case I need to enforce a single association (ie. if you're logged in with a given SAML IdP, you cannot add another association for the same user with the same provider). Is there any python-social-auth solution for this, or should I cobble together something (for instance, preventing logged-in users from accessing the login page)? -
django queryset: how to get items after a particular id in the queryset
I have a list of posts with id: I want to sort all the posts based on publish_date and get all the posts after an id. The following gives me queryset of all posts ordered in publish_date articles = Article.objects.all().order_by('-publish_date') After this how to get queryset with posts after a given id of post -
django api call from api saving into 2 different tables
So i have a function that do an API call from another django project and save the output into its own database. Table Django project 1 : makeapp Django project 2 : Schedule and BookAppt What i want to do is firstly after successfully make a Post request to makeapp API, it will save into Schedule table. And then save the output of makeapp API + Schedule.scheduleId into BookAppt. Is the way to declare a hard coded title using title = "new title" and then save it using "title": title, correct? model class Appointments (models.Model): patientId = models.ForeignKey(MyUser, on_delete=models.CASCADE) clinicId = models.CharField(max_length=10) date = models.DateField() time = models.TimeField() created = models.DateTimeField(auto_now_add=True) ticketNo = models.IntegerField() STATUS_CHOICES = ( ("Booked", "Booked"), ("Done", "Done"), ("Cancelled", "Cancelled"), ) status = models.CharField(max_length=20, choices=STATUS_CHOICES, default="Booked") class BookAppt(models.Model): clinicId = models.CharField(max_length=20) patientId = models.ForeignKey(MyUser, on_delete=models.CASCADE) scheduleId= models.ForeignKey(Schedule, on_delete=models.CASCADE) scheduleTime = models.DateTimeField(blank=True, null=True) ticketNo = models.CharField(max_length=5) status = models.CharField(max_length=20) class Schedule(models.Model): scheduleId = models.AutoField(primary_key=True) userId = models.ForeignKey(MyUser, on_delete=models.CASCADE) title = models.CharField(max_length=100, blank=True, null=True) date = models.DateField() startTime = models.TimeField() views @csrf_exempt def my_django_view(request): if request.method == 'POST': r = requests.post('http://127.0.0.1:8000/api/makeapp/', data=request.POST) else: r = requests.get('http://127.0.0.1:8000/api/makeapp/', data=request.GET) if r.status_code == 201 and request.method == 'POST': data = r.json() print(data) … -
Daphne server command not available
I have created a django app using channels, and tested it with python3 manage.py runserver, which, as I understand, runs a Daphne server as part of the command. Now I just want to deploy the app by running a standalone Daphne server with some workers, etc. following the documentation. Problem is, I don't seem to have the daphne command available to me in the terminal. Running daphne my_project.asgi:channel_layer just results in my terminal telling me the daphne command isn't found. (Running Ubuntu 17.10, if it's at all relevant) Daphne was definitely installed when I installed the channels package using pip. When I run pip3 install daphne it says that I have all the relevant packages and the installation is up-to-date. Am I doing something stupid here? Seems like this just works for everyone else. How can I get the daphne command available to me so I can start a server with it? -
Django TypeError: 'int' object is not callable when trying save data in models
I am trying to save no of values that a question takes into my model the function to do so is listed below, and the no_value field in Models is IntegerField with default value of 0. def _no_value(): questions = Question.objects.all() for question in questions: regex = re.compile('(__[_]*)') no_value = (regex.findall(question.question)) if no_value: value = len(no_value) question.no_value(value) question.save() Please tell me how to fix this error. -
django_countries serializer in django rest framework
I am trying to get the django-countries serialized, but my json does not show all the available countries. I read here django_countries in django rest framework on what the possible solution is but im not getting the result back I should, or that I think I should. This is what my Serializer looks like. from django_countries.serializer_fields import CountryField class LocationsSerializer(serializers.ModelSerializer): country = CountryField() class Meta: model = Location fields = ('location_name', 'address', 'city', 'province', 'postal_code', 'country') And this is what my model looks like. from django_countries.fields import CountryField class Location(models.Model): location_name = models.CharField(max_length=100, default="None") address = models.CharField(max_length=100) city = models.CharField(max_length=100) province = models.CharField(max_length=100) postal_code = models.CharField(max_length=100) country = CountryField() def __str__(self): return self.location_name When I view the json only the saved value is shown and not all the available option to iterate over in my angularjs app. Any direction would be appreciated. -
Disappearing variables on the page after validation - django form
I have a problem with the page after validating the form. After pressing the "Send" button, validation appears - information on which field is required. However, there is no data at the top of the page, e.g. {{event.logo}} etc. Below is the code of my view. model.py class EventDetailView(DetailView, CreateView): model = models.Event form_class = forms.ParticipantForm context_object_name = 'event' template_name = 'events/event_detail.html' def get_success_url(self): return reverse('events:list') def get_initial(self): return {'event': self.kwargs['pk']} url (to view): url(r'^/(?P<slug>[-\w]+)/(?P<pk>[\d]+)$', views.EventDetailView.as_view(), name='detail'), template: {% block content %} <div class="content-item compact bg-mid-gray"> <!--start: event content-text--> <div class="event-container content-inner"> <div class="event-item"> <div class="event-item-date large-2 medium-3 small-12 columns"> <div class="event-time"> <span class="event-date">{{ event.date|date:'d' }}</span> <span class="event-period">{{ event.date|date:'M-d' }}</span> <span class="event-time">{{ event.event_from|date:'H:i' }} - {{ event.event_to|date:'H:i' }}</span> </div> {% if event.logo %} <span class="logo-item"> <img src="{{ event.logo.url }}" alt="logo-item"> </span> {% endif %} </div> <div class="event-item-description large-offset-1 large-9 medium-9 small-12 columns"> <h2>{{ event.title }}</h2> <span class="subtitle">{{ event.flag }}</span> <p>{{ event.text }}</p> </div> </div> </div> <!--end: event content-text--> </div> <!--start: Formular and Info-Box--> <div class="content-item event-form-container"> <div class="content-inner"> <div class="form-container large-offset-1 large-6 medium-7 small-12 columns"> <form id="send-form" class="form-default" action="{{ request.path }}" method="post" novalidate>{% csrf_token %} {% form form using "floppyforms/layouts/p_participant.html" %} <input type="submit" value="Send" class="btn btn-default bg-mid-gray" /> </form> </div> … -
How to add a custom form on django admin.py?
I'm trying to make few fields changeable like title, phone no. for my website. I want to change through admin interface. How can I do that? -
Postgres: display database
I'm using the Django Maybe I'm looking for something wrong or there is basically no such thing. But can someone knows the information about whether it is possible to show database dependencies. Like bdSchema app. Django Rest Framework can build api. I thought maybe there's something that can build a schema -
delete session of a specific user in django?
I am trying to delete the session of some specific user in Django.The code seems to run perfectly fine but I believe session is not deleted as the user is still logged in. The code I am using to delete session is:- user = User.objects.get(id=id) for s in Session.objects.all(): if s.get_decoded().get('_auth_user_id') == user.id: s.delete() -
getting a lot of TransactionManagementError in production servers
Lately getting a lot of errors likes this: An error occurred in the current transaction. You can't " TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block. the exceptions are not in context of tests (like in other stack overflow questions). these exception comes from many different views and apis together at some point of the day. I'm running Django 1.7.1, Python 2.7, MySql 5.7 (Google Cloud Managed) Could it be related to Django DB Sessions? I see this code in SessionStore.save() (\django\contrib\sessions\backends\db.py) with transaction.atomic(using=using): obj.save(force_insert=must_create, using=using) Could a Session save cause other requests to return TransactionManagementError this is the full stack trace: Traceback (most recent call last): File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view return view_func(*args, **kwargs) File "/opt/webapps/tinytap/tinytap-web/reports/api.py", line 573, in track_album_played albumStore = AlbumStore.objects.only('id').get(id=album_store_id) File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/db/models/query.py", line 351, in get num = len(clone) File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/db/models/query.py", line 122, in __len__ self._fetch_all() File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/db/models/query.py", line 966, in _fetch_all self._result_cache = list(self.iterator()) File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/db/models/query.py", line 265, in iterator for row in compiler.results_iter(): File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter for rows in self.execute_sql(MULTI): File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql cursor.execute(sql, params) … -
global name 'DataFile' is not defined
class PageImages(models.Model): page = models.ForeignKey(Pages, on_delete = models.CASCADE) data = models.FileField(blank=True) image = models.CharField(max_length=100) count = models.IntegerField(default = 10) def __str__(self): return self.image def save(self, *args, **kwargs): super(DataFile, self).save(*args, **kwargs) filename = self.data.url I get error while submit form from django-admin. exception global name 'DataFile' is not defined -
Django Forms: Grouping fields from a CheckboxSelectMultiple
I am using Django 2.0.1, Python 3.6.4 and Bootstrap 4.0 models.py from django.db import models class Category(models.Model): name = models.CharField(max_length=255) parent = models.ForeignKey('self',on_delete=models.CASCADE) class AgeRange(models.Model): age_from = models.PositiveIntegerField() age_to = models.PositiveIntegerField() class Item(models.Model): text = models.TextField() category = models.ForeignKey('Category',on_delete=models.CASCADE) age_range = models.ForeignKey('AgeRange',on_delete=models.CASCADE) class Observation(models.Model): links = models.ManyToManyField('Item') forms.py from django.forms import ModelForm from django.forms.widgets import CheckboxSelectMultiple from .models import Observation class ObservationForm(ModelForm): class Meta: model = Observation fields = ['links'] widgets = {'links': CheckboxSelectMultiple} views.py from django.views.generic import CreateView from .models import Observation from .forms import ObservationForm class ObservationCreateView(CreateView): model = Observation form_class = ObservationForm This is meant to model data in the following structure: Category1 Subcategory1 AgeRange1 Item1 Item2 AgeRange2 Item3 Subcategory2 Subcategory3 AgeRange1 Item4 AgeRange2 Item5 Subcategory4 AgeRange1 Item6 AgeRange2 Item7 Category2 Subcategory3 AgeRange1 Item8 Item9 AgeRange2 Item10 Item11 [...] However, by default the form just displays a checkbox for each Item with the text field used as its label. There are potentially a large number of Item objects in the database and just displaying this list without the context of the grouping above would not be very user friendly. So what I am trying to achieve is a set of nested Bootstrap 4 accordians which replicate the … -
Django: Is it a good idea to track user like this?
Is it OK to save a user's(patient) phone number in session if they are not logged-in? I allow user's to book an appointment where they must also provide a mobile phone number which will be verified through OTP system. I am right now using that number to keep track of the user by storing that in session. Should I use that number to keep track of the user and show the appointments that number has against it? I think, it should allow me have a unique ID to track users. Is there a better way to do it if a user hasn't signed up? Are there any serious drawbacks for the user's data etc with what I am doing right now? -
Filter the queryset in the Serializer
I have a I18nField Model: class I18nField(models.Model): page_name = models.CharField(max_length=32) field_code = models.CharField(max_length=256) lang_type = models.CharField(max_length=32) field_lang = models.CharField(max_length=64) unique_together = ('page_name', 'field_code', 'lang_type', 'field_lang') ctime = models.DateTimeField(auto_now_add=True) uptime = models.DateTimeField(auto_now=True) I have the model's Serializer: class I18nFieldListSerializer(ModelSerializer): page_name = serializers.CharField(write_only=True, allow_null=True, allow_blank=True) lang_type = serializers.CharField(write_only=True, allow_null=True, allow_blank=True) class Meta: model = I18nField fields = "__all__" You see, in the I18nFieldListSerializer, I have two serializer fields:page_name and lang_type, if them have value, I will filter from the queryset. I can query this in ListAPIView such as: def get_qeuryset(self): filters = {'{}__contains'.format(key): value for key, value in self.query_params.items() if value is not None} return I18nField.objects.filter(**filters) But whether I can get the list in the Serializer? -
Where to write Django custom validator
Where exactly I have to write the custom validators in Django folder? Below is the folder where I have my models /home/shrivatsa555/childrenGK/cgkapp/models.py I have to validate the question difficulty level in the range of 1, 2 and 3 only: class Questions(models.Model): Question_Number = models.AutoField(primary_key = True), Question_Text = models.CharField(max_length = 1000), Option1 = models.CharField(max_length=500), Option2 = models.CharField(max_length=500), Option3 = models.CharField(max_length=500), Option4 = models.CharField(max_length=500), Answer = models.CharField(max_length=500), Difficulty_Level = models.IntegerField(validators=[validate_number]) I have written a custom validator in the views.py but its not working. Kindly guide me. -
raise TypeError('view must be a callable or a list/tuple in the case of include(). using python-2.7 django-1.11.9
When i run 'python manage.py migrate' ,,it gives me this error :: raise TypeError('view must be a callable or a list/tuple in the case of include().') TypeError: view must be a callable or a list/tuple in the case of include(). THE WHOLE TRACEBACK IS: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/prashant/Desktop/po/local/lib/python2.7/site- packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/management/base.py", line 327, in execute self.check() File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check include_deployment_checks=include_deployment_checks, File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks issues.extend(super(Command, self)._run_checks(**kwargs)) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks return checks.run_checks(**kwargs) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config return check_resolver(resolver) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver return check_method() File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check for pattern in self.url_patterns: File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/prashant/Desktop/po/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/prashant/Desktop/po/cope/urls.py", line 10, in <module> url(r'^', include('opac.urls', … -
Django syndication framework: prevent appending SITE_ID to the links
According to the documentation here: https://djangobook.com/syndication-feed-framework/ If link doesn’t return the domain, the syndication framework will insert the domain of the current site, according to your SITE_ID setting However, I'm trying to generate a feed of magnet: links. The framework doesn't recognize this and attempts to append the SITE_ID, such that the links end up like this (on localhost): <link>http://localhost:8000magnet:?xt=...</link> Is there a way to bypass this? -
Define Django testing database
I am working on django testing. problem is need to specify a database for test which is already created and tables have data inside. I want to use this database for testing. how can i do that. -
Python, Django , Jet dashboard
I am just stepping in python with django framework. And now I want my admin dashboard with better ui with jet dashboard. I have done everything exact same as in the documentation of jet documentation link. In my setting.py JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard' JET_APP_INDEX_DASHBOARD = 'dashboard.CustomAppIndexDashboard' And in my dashboard.py class CustomIndexDashboard(Dashboard): columns = 3 def init_with_context(self, context): self.available_children.append(modules.LinkList) self.available_children.append(modules.Feed) self.available_children.append(google_analytics.GoogleAnalyticsVisitorsTotals) self.available_children.append(google_analytics.GoogleAnalyticsVisitorsChart) self.available_children.append(google_analytics.GoogleAnalyticsPeriodVisitors) site_name = get_admin_site_name(context) # append a link list module for "quick links" self.children.append(modules.LinkList( _('Quick links'), layout='inline', draggable=False, deletable=False, collapsible=False, children=[ [_('Return to site'), '/'], [_('Change password'), reverse('%s:password_change' % site_name)], [_('Log out'), reverse('%s:logout' % site_name)], ], column=0, order=0 )) # append an app list module for "Applications" self.children.append(modules.AppList( _('Applications'), exclude=('auth.*',), column=1, order=0 )) # append an app list module for "Administration" self.children.append(modules.AppList( _('Administration'), models=('auth.*',), column=2, order=0 )) # append a recent actions module self.children.append(modules.RecentActions( _('Recent Actions'), 10, column=0, order=1 )) # append a feed module self.children.append(modules.Feed( _('Latest Django News'), feed_url='http://www.djangoproject.com/rss/weblog/', limit=5, column=1, order=1 )) # append another link list module for "support". self.children.append(modules.LinkList( _('Support'), children=[ { 'title': _('Django documentation'), 'url': 'http://docs.djangoproject.com/', 'external': True, }, { 'title': _('Django "django-users" mailing list'), 'url': 'http://groups.google.com/group/django-users', 'external': True, }, { 'title': _('Django irc channel'), 'url': 'irc://irc.freenode.net/django', 'external': True, }, ], column=2, order=1 )) … -
ImproperlyConfigured: The SECRET_KEY setting must not be empty when run kobocat
I am trying to set up kobocat When I try to run ./manage.py runserver I am getting the following error: Here is the full error message: Traceback (most recent call last): File "manage.py", line 20, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 279, in execute saved_locale = translation.get_language() File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 154, in get_language return _trans.get_language() File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 52, in __getattr__ if settings.USE_I18N: File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__ self._setup(name) File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 49, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 151, in __init__ raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.") django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty. -
Django: Can I use a filter to return objects where a condition is valid across an entire related set?
My objects are set up similar to this: class Event(Model): pass class Inventory(Model): event = OneToOneField(Event) def has_altered_item_counts(self): return any(obj.field_one is not None or obj.field_two is not None for obj in self.itemcounts_set.all()) class ItemCounts(Model): inventory = ForeignKey(Inventory) field_one = IntegerField(blank=True, null=True) field_two = IntegerField(blank=True, null=True) Basically, I'd like to filter uniquely on Event where inventory.has_altered_item_counts would return False I have Q(inventory__itemcounts__field_one__isnull=True) & \ Q(inventory__itemcounts__field_two__isnull=True) but that returns the event every time it meets those conditions. Given that result, I want to exclude that event if the number of times it appears is less than the total number of item counts. Does any of this make sense? Is this possible with filter? I really sort of need it to be, this is part of a programmatically built batch update -
how to represent class instances in another class
I am new to django and I want to represent instances of class Item in class Category ( so when I go to pizza category I want to see margarita pizza and any other created item ) so here is my admin interface and this is the pizza categorie Item margarita pizza in Items table and this is my models.py code from django.db import models class Customer (models.Model): name = models.CharField(max_length=500) email = models.CharField(max_length=1000 , unique=True) phone = models.IntegerField() address = models.CharField(max_length=3000) class Category(models.Model): name = models.CharField(max_length=100 , unique=True) def __str__(self): return self.name class Order (models.Model): time = models.DateTimeField(auto_now_add=True) total = models.IntegerField() created_by = models.ForeignKey(Customer, related_name='orders') class Item (models.Model): name = models.CharField(max_length=100 ,unique=True) details = models.CharField(max_length=1000) price = models.IntegerField() item_logo = models.ImageField(upload_to='res/images') category = models.ForeignKey(Category , related_name='items' , on_delete= models.CASCADE) def __str__(self): return self.name -
how to create a url pattern on path(django 2.0) for a *item*_id in django
Here's my code from django.urls import path urlpatterns = [ # /audios/ path('', views.audio ), # /audios/4344/ path('(<record_id>[0-9]+)/', views.record_detail), ] Please can someone help out -
How do I trace UnicodeDecodeError: 'utf8' codec can't decode byte 0x85 in position 1950: invalid start byte
Am trying to run an app in development but I keep getting UnicodeDecodeError: 'utf8' codec can't decode byte 0x85 in position 1950: invalid start byte Please how do trace the exact part of the code where this is coming from as I can't make sense of it's error source Below is the full error screen {u'selected': {}, u'categories': {u'ratings': ((1, u''), (2, u''), (3, u''), (4, u'****'), (5, u'*****')), u'genre s': , u'actors': , u'directors': }} Internal Server Error: /movie/ Traceback (most recent call last): File "c:\python27\lib\site-packages\django\core\handlers\exception.py", line 41, in inner response = get_response(request) File "c:\python27\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "c:\python27\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Roland\Documents\Web2\myproject_env\myproject2\movies\views.py", line 70, in movie_list return render(request, "movies/movie_list.html",context) File "c:\python27\lib\site-packages\django\shortcuts.py", line 30, in render content = loader.render_to_string(template_name, context, request, using=using) File "c:\python27\lib\site-packages\django\template\loader.py", line 67, in render_to_string template = get_template(template_name, using=using) File "c:\python27\lib\site-packages\django\template\loader.py", line 21, in get_template return engine.get_template(template_name) File "c:\python27\lib\site-packages\django\template\backends\django.py", line 39, in get_template return Template(self.engine.get_template(template_name), self) File "c:\python27\lib\site-packages\django\template\engine.py", line 162, in get_template template, origin = self.find_template(template_name) File "c:\python27\lib\site-packages\django\template\engine.py", line 136, in find_template name, template_dirs=dirs, skip=skip, File "c:\python27\lib\site-packages\django\template\loaders\base.py", line 38, in get_template contents = self.get_contents(origin) File "c:\python27\lib\site-packages\django\template\loaders\filesystem.py", line 29, in get_contents return fp.read() File …