Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
In django form. there is no error message to rasie
I'm tried to build a blog with django+xadmin. when I coding the login module, with the form to validate the username and password. So I use forms to do this. In forms.py: from django import forms class LoginForm(forms.Form): username = forms.CharField(required=True,) password = forms.CharField(required=True, min_length=5) In views.py: from django.views.generic.base import View # Create your views here. from .models import UserProfile from .forms import LoginForm class CustomBackend(ModelBackend): def authenticate(self, username=None, password=None, **kwargs): try: user = UserProfile.objects.get(Q(username=username)|Q(email=username)) if user.check_password(password): return user except Exception as e: return None class LoginView(View): def get(self, request): return render(request, "login.html", {}) def post(self, request): login_form = LoginForm(request.POST) if login_form.is_valid(): user_name = request.POST.get("username","") pass_word = request.POST.get("password","") user = authenticate(username=user_name, password=pass_word) if user is not None: login(request,user) return render(request,"index.html") else: return render(request, "login.html", {"msg": "username or password is uncorrect", }) else: return render(request,"login.html",{"login_form":login_form.errors}) when I set a breakpoint at the if login_form.is_valid(): and I test it with the username and password are blank in the loginpage. But the is nothing error raised. And when I watch the detail of login_form , the _errors is none,It shouldn't lick this. What should I change my code to repair this error. -
How to link my django project to apache2 in raspbian jessie
I have my django project, and i have installed apache2 both in my raspberry pi 3. The OS is raspbian jessie. Apche2 is quite different in debian jessie based system. I see a lot of info for regular apache2 with django but not with debian apache2 with django. -
The view chilegaleria.views.AgregarTienda_View didn't return an HttpResponse object. It returned None instead
hello to all and i hope you are having a good day i'm getting this error i'm using django 1.10.6 ValueError at /AgregarTienda The view chilegaleria.views.AgregarTienda_View didn't return an HttpResponse object. It returned None instead. this is my view from django.shortcuts import render from django.http import HttpResponse from chilegaleria.forms import AgregarTiendaForm # Create your views here. def index(request): return render(request, 'chilegaleria/index.html') def AgregarTienda_View(request): if request.method == 'POST': form = AgregarTiendaForm(request.POST) if form.is_valid(): form.save() return redirect('chilegaleria:index') else: form = AgregarTiendaForm return render(request, 'chilegaleria/AgregarTienda.html', {'form':form}) also when i add class Meta: model = DatosTienda to my forms.py file i get this error C:\chilegalerias>manage.py check Traceback (most recent call last): File "C:\chilegalerias\manage.py", line 22, in execute_from_command_line(sys.argv) File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\management__init__.py", line 367, in execute_from_command_line utility.execute() File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\management__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\management\base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\management\base.py", line 345, in execute output = self.handle(*args, **options) File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\management\commands\check.py", line 68, in handle fail_level=getattr(checks, options['fail_level']), File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\management\base.py", line 374, in check include_deployment_checks=include_deployment_checks, File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\management\base.py", line 361, in _run_checks return checks.run_checks(**kwargs) File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\checks\urls.py", line 14, in check_url_config return check_resolver(resolver) File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\core\checks\urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "C:\Python27\lib\site-packages\django-1.10.6-py2.7.egg\django\utils\functional.py", line 35, in … -
Server requirements for modest Django application
I have a Django application that is a simple form. I will have 2,000 visitors coming to the server over the period of a few hours to complete the form. I want to use AWS. Will a t2.micro instance support this application without any downtime? I am currently developing the application on the free tier (micro). Amazon has not responded to my request for to increase to a larger instance. Will a t2.micro instance with apache, mysql and nothing else installed support my application? -
Django queries and specific sorting
I am quite new to Django and it's way of doing queries. I think I got the basics now but I'm stuck at a sorting problem. So let's say I have this example model: class Word_List(models.Model): list_name = models.CharField(max_length=64) number_of_words = models.IntegerField(default=0) I have a few data : pk list_name number_of_words 1 vegetables 30 2 fruits 5 3 animals 7 4 objects 15 5 instruments 16 6 fruits 28 Now I want them to be sorted by the number_of_words and then grouped by list_name with the top list being the important one in the grouping. Here, a clearer explanation with the sorted elements I have in mind : pk list_name number_of_words 1 vegetables 30 6 fruits 28 2 fruits 5 5 instruments 16 4 objects 15 3 animals 7 I have tried a few things but I never fully reached what I wanted. I started with this : sorted_lists = Word_List.objects.all().order_by('-number_of_words') Of course it wasn't enough as it only sort every element regardless of their names so I tried this one : sorted_lists = Word_List.objects.all().order_by('list_name', -'number_of_words') And ended up with this result : pk list_name number_of_words 3 animals 7 6 fruits 28 2 fruits 5 5 instruments 16 4 objects … -
How can i store a entry only once in django
I am making a model in django to subscribe. I am getting email id from user . I want when user enter same email id twice it did not store and shows message to user that you are already subscribed. -
Edit and update HTML datatable Django
I just builded a system in Django 1.10 that basically is a form that users can fill up and generates technical issues from orders. As seen in the picture below: Once the issue is submitted to the database below is a table where all the issues appear: This is my model: class TechnicalValidationSystem(models.Model): user = models.ForeignKey(User) author = models.CharField(max_length=30) soss = models.CharField(max_length=30) case_opened = models.CharField(max_length=30) cause_reason = models.CharField(max_length=35) date_created = models.DateTimeField(blank=True, null=True) comments = models.CharField(max_length=500) issue_solved = models.BooleanField(default=False) This is my HTML table: <div class="table-responsive"> <table class="table table-striped table-bordered table-hover dataTables-example" > <thead> <tr> <th>SO-SS</th> <th>Case Opened</th> <th>Cause Reason</th> <th>Comments</th> <th>Date Created</th> <th>Created by:</th> <th>Issue Solved?</th> </tr> </thead> <tbody> {% for linea in lineas_de_reporte %} <tr> <td>{{ linea.soss }}</td> <td>{{ linea.case_opened }}</td> <td>{{ linea.cause_reason }}</td> <td>{{ linea.comments }}</td> <td>{{ linea.date_created }}</td> <td>{{ linea.author }}</td> <td>{{ linea.issue_solved }}</td> </tr> {% endfor %} </tbody> </table> </div> What I need now is to find a way users can modify this table mainly if the issue was solved or not and to update my database with that response. Anyone know how to do this with just django? if not maybe use Jquery or anything else. Let me know if you guys need something else … -
Unable to startproject due to settings.py not found
(env_mysite) C:\Users\acer>django-admin startproject mysite Traceback (most recent call last): File "d:\ash\software\python3\Lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "d:\ash\software\python3\Lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\acer\env_mysite\Scripts\django-admin.exe__main__.py", line 9, in File "c:\users\acer\env_mysite\lib\site-packages\django\core\management__init__.py", line 367, in execute_from_command_line utility.execute() File "c:\users\acer\env_mysite\lib\site-packages\django\core\management__init__.py", line 316, in execute settings.INSTALLED_APPS File "c:\users\acer\env_mysite\lib\site-packages\django\conf__init__.py", line 53, in __getattr__self._setup(name) File "c:\users\acer\env_mysite\lib\site-packages\django\conf__init__.py", line 41, in _setup self._wrapped = Settings(settings_module) File "c:\users\acer\env_mysite\lib\site-packages\django\conf__init__.py", line 97, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "c:\users\acer\env_mysite\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 978, in _gcd_import File "", line 961, in _find_and_load File "", line 936, in _find_and_load_unlocked File "", line 205, in _call_with_frames_removed File "", line 978, in _gcd_import File "", line 961, in _find_and_load File "", line 948, in _find_and_load_unlocked ModuleNotFoundError: No module named 'C:\Users\acer\mysite\mysite\settings' -
Extracting URL parameters to update Django app database
I want to extract parameters from a URL and use them to update the database in a Django app. One page of the app contains a jQuery script that sends out an ajax GET request of the form http://127.0.0.1:8000/storelatlong/?lng=56.237244700410336&lat=-4.6197509765625 containing user input information as its lat and lng parameters. I want to retrieve that information and use it to update my UserProfile.latitude and UserProfile.longitude values stored in my database. So, I've got two basic questions: How do I get the parameter info into a views.storelatlong? Once the information's there, how do I use it to update models.UserProfile? urls.py url(r'^storelatlong/$', views.storelatlong, name='storelatlong'), views.py def storelatlong(request): context_dict = {'': ''} lat = float(request.GET.get('lat', '')) lng = float(request.GET.get('lng', '')) return HttpResponse("OK") models.py class UserProfile(models.Model): user = models.OneToOneField(User) phone_number = models.CharField(max_length=16, blank=True) gender_male = models.BooleanField() post_code = models.CharField(max_length=7) longitude = models.FloatField(null=True, blank=True) latitude = models.FloatField(null=True, blank=True) def __str__(self): return self.user.username def __unicode__(self): return self.user.username Currently, sending out the GET request just results in my getting 301 (moved permenantly) and 500 (internal server error) messages in the browser and the following in the command line server: [10/Mar/2017 15:43:28] "GET /storelatlong lng=56.359671608143785&lat=-5.23773193 359375 HTTP/1.1" 301 0 Internal Server Error: /storelatlong/ Traceback (most recent call last): File … -
django registration redux not redirecting to base.html after login
I am working on a e-comm application, I am using django registration redux to setup user registration and login. Initially when I set up the register/login system it was working fine..when I put bootstrap and styles in my base.html, the functionality broke and after user login rather it redirecting to base.html..it tries to fetch http://localhost:8000/accounts/login/, this url.. I can't seem to figure out the reason. Here is my settings.py Also to note, when I put 'store' at the last in Installed apps section and try to click login/register url comes back to base.html rather than login/register pages. """ Django settings for bookstore project. Generated by 'django-admin startproject' using Django 1.8. For more information on this file, see https://docs.djangoproject.com/en/1.8/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '&icg8)16be&h!rw)6_#3#v!1dn5nx_*k1rv7lx@c(88tw5z6$a' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'social.apps.django_app.default', … -
Error creating new content types. Please make sure contenttypes
I am getting this error while try to migrate my django project. I tried all solutions available on stackoverflow but my problem is not getting solved. I tried python manage.py makemigrations i am getting no changes detected and when migrate ,i am getting this error. "Error creating new content types. Please make sure contenttypes " RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually. I also tried migrate individual app but that also not solve my problem.i amstuck at this point .At this stage i am able to runserver but when i am trying to open django admin i am getting this error (1146, "Table 'microbird.django_session' doesn't exist") All this happening when i am trying to change my database from sqlite3 to mysql. -
coverage in parallel for django tests
I am running the following through a Makefiel: NPROCS:=$(shell /usr/bin/nproc) .PHONY: coverage-app coverage-app: coverage erase --rcfile=./.coveragerc-app coverage run --parallel-mode --rcfile=./.coveragerc-app manage.py test -v 3 --parallel=$(NPROCS) app coverage combine --rcfile=./.coveragerc-app coverage report -m --rcfile=./.coveragerc-app If I set NPROCS to 1, I get the expected 100% test coverage of all files within app. However, if NPROCS is greater than 1, I get lots of missing lines in my report. What am I doing wrong? My .coveragerc-app is as follows: # Control coverage.py [run] branch = True omit = */__init__* */test*.py */migrations/* */urls.py app/admin.py app/apps.py source = app parallel = true [report] precision = 1 show_missing = True ignore_errors = True exclude_lines = pragma: no cover raise NotImplementedError except ImportError def __repr__ if self\.logger\.debug if __name__ == .__main__.: -
Django include template
The Django Doc states that includes are rendered with their own variables and settings. I have a big template that consists of a lot of widgets, which, for better structure i would like to have each in its own file. For this I'm using the include template tag, which in this scenario has two drawbacks: Pass every template variable from the parent template to the include tag Load the whole set of template tags and filter within each included template This is not DRY and probably bad for performance as well. Is there a better practice to do this? -
Django silent fail on large Response
i'm currently getting started with django and noticed a strange problem, that when a response is too big, it will silently fail and not send any data at all. i've tested this with a JsonResponse that contains a given set of data in a field, that works perfectly fine. {"data": { "hplcdata": { "ADC": adcdata, } }} If i put that same set of data into another field on the same json result, it will fail silently. (Resulting in a ERR_EMPTY_RESPONSE in chrome). {"data": { "hplcdata": { "ADC": adcdata, "ADC2": adcdata, } }} i've also tested this with a self-implemented JsonResponse type that consists of a view with a single variable that will be set and safe-mode disabled, resulting in the same empty response. The Log in the first case looks like this: Starting development server at http://0.0.0.0:8088/ Quit the server with CTRL-BREAK. [10/Mar/2017 15:38:27] "GET /api/HplcData/3/5 HTTP/1.1" 200 302714 In the second case it looks like this: Starting development server at http://0.0.0.0:8088/ Quit the server with CTRL-BREAK. [10/Mar/2017 15:39:47] "GET /api/HplcData/3/5 HTTP/1.1" 200 605415 It does not seem to be a browser issue either, since firefox responds in the same way. At first i thought it was a graphql … -
Module Loads In Django Shell/Dev But Issues In Prod
Ive been working on this issue for two days now, I have a module thats loaded in my app, when I do a python manage.py shell I can load and work with it fine as well as a runserver, it all works great. However, when I try to load it in a view on a production server, I cant seem to get it work getting a "cannot import name pywraplp". I have ran out of ideas and looking for some advice on what else I can do to try to get this to work. Im running nginx,gunicorn,uwsgi -
Multi Count Annotation
Hi i try to crete annotation like this: product= Game.objects.order_by('name').annotate( clot_count=models.Count( models.Case( models.When(clot__lot_status=True, clot__stock__gte=F('clot__min_order'),then=1) ), distinct= True ), g_count=models.Count( models.Case( models.When(glot__lot_status=True,then=1) ), distinct=True ), ) I try to use distinct=True but annotation don't work correctly. Thx for help -
Django CMS Multisite User Permissions
Im starting a project using Django CMS that has multiple sites being controlled from one instance of Django CMS. I have found the documentation for User Permissions and Group Permissions but didn't see anything by default about permissions depending on which site the user is on. I want to be able to give user a group and have them only be able to login to a specific site(s). Im sure this is going to be possible by requesting the current SITE_ID but I just wanted to see if anyone could point me in the right direction of a plugin or middleware that might let me do this? Any advice would be greatly appreciated. -
Why does Python/Django keep redirecting to another URL?
I'm stepping into the Python world. First I learned a little Python. Then I learned the basics of Django, and on top of that I'm learning Wagtail (framework for template managing for Django) To learn Django a went through a tutorial to build a site locally and test it in 127.0.0.1:8000. At some point of the tutorial I configured the settings (because the tutorial said so) to redirect to 127.0.0.1:8000/catalog when browsing to 127.0.0.1:8000 alone. Then I started the Wagtail tutorial, as a completely different project in another folder. Not sharing any code with the basic Django proyect. I run the server that the console says is now running in port 127.0.0.1:8000 and when I browse it, it redirects me to /catalog and of course shows a Page not found error since this project doesn't have one app catalog. I workaround this by opening Chrome in Incognito Mode. But still I would like to know why this is happening and how to solve it to add to my knowledge of how Python works. Some notes: I'm on Windows I killed all processes related to Python and actually this is still happening after turning my PC off and on I know … -
Should I sacrifice performance over readability
I'm developing a django rest service. Me and my colleague are currently in an argument about django models. We have a model named Report which contains field/fields about location (longitude, latitude, address, city, postal code). Does it make sense that I want to make location a separate model? Other models may also use this location model. Here is what I mean: class Location(models.Model): address = models.CharField(max_length=200) city = models.CharField(max_length=100) postal_code = models.CharField(max_length=10) latitude = models.FloatField() longitude = models.FloatField() class Report(models.Model): user = models.ForeignKey(User) description = models.CharField(max_length=500) datetime = models.DateTimeField(auto_now_add=True) location = models.OneToOneField(Location) I know that for every query on report there has to be another query on location, but I think it's worth it, because it looks much more clean to me and other models can also use this Location model, without copying fields. Thanks -
Extra raise error in admin page
I have problem in my admin page when I try to edit. In the picture below you can see it ("Field is required" in extra line). When I try to edit I see one extra line. I am little bit customized Membership block with my own form cause I want to show to admin in 'role' field only 'manager' value. It works but edit raise error. By the way when I dont use custom form edit work without problem despite the fact that there are extra line. Here below you can see my code. So I am comfused with that. How can I solve this problem? I also tried to use in form __init__ this self.fields['user'].required = False and self.fields['role'].required = False but it didnt help. models.py: class Project(models.Model): ***FIELDS*** members = models.ManyToManyField(User, through='Membership',) ROLE_CHOICES = ( ('manager', 'Manager'), ('developer', 'Developer'), ('business_analyst', 'Business analyst'), ('system_analysts', 'System analysts'), ) class Membership (models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) project = models.ForeignKey(Project, on_delete=models.CASCADE) role = models.CharField(max_length=20, choices=ROLE_CHOICES,) admin.py: class MembershipInline(admin.TabularInline): model = Membership form = MembershipAdminForm extra = 1 class MembershipAdmin(admin.ModelAdmin): inlines = (MembershipInline,) admin.site.register(Project, MembershipAdmin) forms.py: class MembershipAdminForm(forms.ModelForm): class Meta: model = Membership fields = '__all__' def __init__(self, *args, **kwargs): super(MembershipAdminForm, self).__init__(*args, **kwargs) … -
mongoengine.connection.ConnectionError with django
I am trying to build a django rest framework application with mongodb backnd , for which I am using mongoengine. According to issues #935 of mongoengine (closed already in github) say, had to go down to the version of mongoengine and that of pymongo for django. Then my versions are as follows: pymongo 2.8, mongoengine 0.9, python 2.7, django 1.10 I have configured settings.py according to the documentation of mongoengine 0.9, however I have this connection error, I would appreciate some help, @mongoengine @contributors <p>lib/python2.7/site-packages/mongoengine/connection.py", line 126, in get_connection raise ConnectionError("Cannot connect to database %s :\n%s" % (alias, e)) mongoengine.connection.ConnectionError: Cannot connect to database default : command SON([('saslStart', 1), ('mechanism', 'SCRAM-SHA-1'), ('autoAuthorize', 1), ('payload', Binary('n,,n=mongo,r=MzYxNTkyNzU5Njg4', 0))]) on namespace formkeep_db.$cmd failed: Authentication failed. </p> lib/python2.7/site-packages/mongoengine/connection.py", line 126, in get_connection raise ConnectionError("Cannot connect to database %s :\n%s" % (alias, e)) mongoengine.connection.ConnectionError: Cannot connect to database default : command SON([('saslStart', 1), ('mechanism', 'SCRAM-SHA-1'), ('autoAuthorize', 1), ('payload', Binary('n,,n=mongo,r=MzYxNTkyNzU5Njg4', 0))]) on namespace formkeep_db.$cmd failed: Authentication failed. -
Test redirect using @user_passes_test decorator
My view file has: def is_authorised(user): return user.groups.filter(name='bookkeepers').exists() @login_required def unauthorised(request): context = {'user': request.user} return render(request, 'order_book/unauthorised.html', context) @login_required @user_passes_test(is_authorised, login_url='/order_book/unauthorised/', redirect_field_name=None) def book(request): return render(request, 'order_book/book.html', {}) I want to write a test asserting that a logged in user who is not authorised does get redirected correctly, so far I have this: class RestrictedViewsTest(TestCase): @classmethod def setUpTestData(cls): # noqa """Set up data for the whole TestCase.""" User.objects.create_user(username='JaneDoe', email='jane.doe@example.com', password='s3kr3t') def setUp(self): auth = self.client.login(username='JaneDoe', password='s3kr3t') self.assertTrue(auth) def test_book(self): response = self.client.get('/order_book/book') self.assertEqual(response.status_code, 301, response) self.assertTrue(isinstance(response, HttpResponsePermanentRedirect)) def tearDown(self): self.client.logout() This works fine as it is but I cannot fathom where to get the redirected to url. Trying to get response.get['Location'] gives me '/order_book/book' which is not right. What am I doing wrong? -
Django makemigrations writes fake files
I'm getting an odd error when I make the i18n files of a django project: (venv) user@machine:~/path/to/repo$ django-admin makemessages -l es It creates fake .py files for every .txt files: For example, requirements/base.txt Django==1.10.6 django-environ==0.4.1 djangorestframework==3.6 psycopg2==2.7 djangorestframework-jwt==1.9.0 Markdown==2.6.8 unipath==1.1 It generates a requirements.base.txt.py with 'XXXXXX' in it: XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXX XXXXXXXXXXXX But it also creates the right .po files into /locale Could you please point me in the right direction? Because I'm lost. Thank you! -
Django CORS and CSRF, Embedding dynamic wizard on client website
My website offers booking functionality. Each user is allowed to create his own reservation system and configure it to his needs(add services, categories, team members and such). At the moment each reservation system created by user can be accessed on my django website, making a reservation doesn't require a user to be logged in, nor does it save any information about user that placed the reservation. Identifying someone who placed the reservation is based on e-mail adress provided at the end of the wizard. To make reservation possible i created 4 step dynamic wizard(django templates with ajax requests), that is accessed by each system website through an ajax request. As you might imagine each systems reservation page is very generic and users that create reservation system on my website might want to embed the dynamic wizard on their own websites(pure front-end). I'd like to allow my users to do so in such a way, that the only thing they have to do is include jquery, css stylesheet and ajax request to fill their div with my wizard: <div id="reservation-wizard"></div> <script> $(document).ready(function(){ $.ajax({ type: 'GET', url: 'http://127.0.0.1:8000/b/system_owner_name/system_name/reservation-wizard/', success: function(data){ $('#reservation-wizard').html(data); } }); }); </script> So far the first problem i encountered … -
Permission denied in Django makemessages
I'm trying to add i8n into a Django app, but when I execute: (venv) user@machine:~/path/to/repo$ django-admin makemessages -l es The next error is thrown: PermissionError: [Errno 13] Permission denied: './venv/lib/python3.5/site-packages/Jinja2-2.9.5.dist-info/LICENSE.txt.py' But if I use it with manage.py instead of django-admin it works correctly. In django documentation they recommend to use django-admin. Any ideas?