Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I get an out of range error even if I check object exists
I have the following method within a model. The method checks if an object exists before doing anything, however I get an list index out of range error even though I'm checking if the object exists. The error I get when I test the method using the shell is: >>> m.add_to_group() Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Users\Philip\CodeRepos\Acacia2\monzo\models.py", line 61, in add_to_group if Merchant.objects.filter(merchant_group__isnull=False,name=self.name).exists(): File "C:\Users\Philip\CodeRepos\Acacia2\venv\lib\site-packages\django\db\models\query.py", line 314, in __getitem__ return qs._result_cache[0] IndexError: list index out of range >>> def add_to_group(self): """ If not already in a group then searches for matching merchants already in a group and adds itself. If none found then creates new group for itself. """ if Merchant.objects.filter(merchant_group__isnull=False,name=self.name).exists(): matched_merchant = Merchant.objects.filter(merchant_group__isnull=False,name=self.name)[0] # Add to existing group self.merchant_group = matched_merchant.merchant_group self.save() else: # Create new group and add merchant to it new_group = MerchantGroup(name=self.name) self.merchant_group = new_group new_group.save() self.save() -
https://drive.google.com/open?id=1xZa3UoXZ3uj2j0Q7653iBp1NrT0gKj0Y
This JSON file describes a list of users & their corresponding periods of activity across multiple months. Now, design and implement a Django application with User and ActivityPeriod models, write a custom management command to populate the database with some dummy data, and design an API to serve that data in the json format given above. -
Django's ManyToManyField column of model isn't showing in database
I created two models in Django and used 'subcode' as ManyToManyField to create a relation between them. But after migration the column with ManyToManyField is missing in the database table. class Subject(models.Model): Subject_Name = models.CharField(max_length=200) Subject_Code = models.CharField(max_length=200) Max_Marks = models.IntegerField() Course = models.CharField(max_length=200) Branch = models.CharField(max_length=100) Semester = models.IntegerField() def __str__(self): return self.Subject_Code class Marks(models.Model): roll = models.IntegerField() subcode = models.ManyToManyField(Subject,related_name='subjects',default=2) marks = models.IntegerField() sheet = models.FileField(upload_to='marksheet') I checked the table for "Marks" model. But it only has (id,roll,marks,sheet) and it is missing the 'subcode' column. And now I cannot save 'subcode' using form because the 'subcode' column is missing in the table. How to fix this ? -
Affect readonly and disabled widget attributes on clean method of Django Forms
I used readonly and disabled widget attributes on my forms like this: self.fields['my_field'].widget.attrs['readonly'] = True self.fields['my_field'].widget.attrs['disabled'] = True and then I override clean method of this: def clean_my_field(self): # Edit if self.instance and self.instance.pk: if self.cleaned_data.get('my_field') != self.instance.my_field: raise ValidationError(INVALID_VALUE_ERROR) else: return self.instance.my_field # Create else: if self.cleaned_data.get('my_field') != self.other_value: raise ValidationError(INVALID_VALUE_ERROR) else: return self.cleaned_data.get('my_field') When I submit the form, I get validation error that: my_field is required What is relation between readonly and disabled attributes with clean method of django forms? -
How to change Django admin go button
admin.py from django.contrib import admin from .models import Data from import_export.admin import ImportExportModelAdmin # Register your models here. @admin.register(Data) class ExportDataAdmin(ExportActionModelAdmin): # readonly_fields=['Measurement_Date'] list_display=['Measurement_Date','config_id','user_id','device_id'] when I choose a action,For example,I choose delete,and I need to click a button name 'Go' button. And now,I want to change this 'go' button's name to others string values. What should I do? This is button I want to change -
How can I pass a JWT token to test the function?
I use unit tests. to test the function, I need to explicitly pass the token, if I don't do this, the function returns 400. If I comment on a line with simple.JWTToken in the settings, everything works fine. Q: how can I pass a token to my test? I'm using DRF. def test_delete_murr_valid_parameters(self): user = Murren.objects.create_user(username='loku', password='123456', email='onar@gmail.com') """user.id = 3""" user.save() print(user) self.client.force_login(user=user) delete_path = reverse('MurrCardView') user_request = self.client.delete(delete_path, data={'murr_id': 1, 'owner_id': 3}, format='json') self.assertEqual(user_request.status_code, 204) -
Django keeps giving error 'ArticleView' should either include a `serializer_class` attribute, or override the `get_serializer_class()` method
I already solved the problem by adding serializer_classes but it keeps giving me the same error. It did the same to me before even if i solved it . Did i miss something here? Views.py class ArticleView(CreateAPIView): serializer = ArticleCreateSerializer permission_classes = (IsAuthenticated,) def post(self, request, format=None): try: serializer_context = { 'request': request } serializer_data = request.data.get('article',{}) serializer = self.get_serializer_class(data=serializer_data, context=serializer_context, ) if serializer.is_valid(): serializer.save() return Response({'success': True}) else: return Response({'success': False}) except: return Response({'success': False}) Serializers.py class ArticleCreateSerializer(serializers.ModelSerializer): caption = serializers.CharField(required=False) author = UserSerializer(read_only=True) class Meta: model = Article fields = ('id','author','caption') def create(self, validated_data): author = self.context['request'].user.profile article = Article.objects.create(author=author,**validated_data) return article Does anyone knows why?? -
Django suddenly can't load static files anymore
I have a django project for which suddenly (after updating PyCharm) the staticfiles can't be loaded anymore. This is the project structure: ├── _quanttool │ ├── _quanttool │ │ ├── __init__.py │ │ ├── asgi.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── _static │ │ ├── css │ │ ├── img │ │ ├── js │ │ ├── scss │ │ └── vendor │ ├── _templates │ │ ├── base │ │ ├── funds_tool │ │ └── transaction_list │ ├── funds_tool . . . │ ├── db.sqlite3 │ └── manage.py ├── venv ├── .gitignore └── README.md In the settings.py file i have configured: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) STATIC_URL = '/_static/' STATIC_ROOT = '_static' STATICFILES_LOCATION = [os.path.join(BASE_DIR, '_static')] In the base HTML Template I have set {% load static %} and <link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet"> I really don't understand why I suddenly get the errors: "GET /_static/css/sb-admin-2.css HTTP/1.1" 404 1682" ... Any idea why Django can't find the staticfiles anymore? Best -
How two Django applications use same database for authentication
previously we implemented one django application call it as "x" and it have own database and it have django default authentication system, now we need to create another related django application call it as "y", but y application did n't have database settings for y application authentication we should use x applications database and existing users in x application, so is it possible to implement like this?, if possible give the way how can we use same database for two separated django applications for authentication system. Sorry for my english Thanks for spending time for my query -
Django views suggestion for optimized code
I made an app with 7 models and made a template to summarize the data in pivot-like format, category-wise count of objects for each month and sum as example like below. Description - Jan - Feb .... - Dec - Cumulative category1.......1.......0............2............3 category2.......2.......1............1............4 ... category16.....1.......4............2............7 Over All...........4......5............5...........14 and another table for calculated fields from above table, exactly the same format but with calculations and a few more similar tables. I am generating all the data by iterating through models and appending a list or a dictionary, making calculations etc. So I have lots of for loops. From the view function I'm passing 26 dictionaries to the template. I'm sure this is not the best practice so I need your suggestions on how to improve this. -
How to pass html tag to wkhtmltopdf using django?
I'm passing string with html tag from my django view to html and want to create pdf report. views.py: name = "Ford.png" res = "Old ford <img src='{% static 'repo/"+name+"' %}'/>" context = {'data': res} response = PDFTemplateResponse(request=request, template=template, filename="report.pdf", context=context, show_content_in_browser=True, cmd_options={'margin-top': 15, 'javascript-delay': 1000, }, ) return response in html: {{ data }} I got correct string <img src='{% static 'repo/Ford.png' %}'/> , but image is not image. changing in html to: {{ data |safe }} throws an error `CalledProcessError`. Static works correctly. -
How to get the current object / product from the class based detail view in django?
'''Models Code''' # Product Model class Products(models.Model): name = models.CharField(max_length=50) img = models.ImageField(upload_to='productImage') CATEGORY = ( ('Snacks','Snacks'), ('Juice','Juice'), ) category = models.CharField(max_length=50, choices=CATEGORY) description = models.TextField() price = models.FloatField() # Rating Model class Rating(models.Model): product = models.ForeignKey(Products, on_delete=models.CASCADE) user = models.ForeignKey(User, on_delete=models.CASCADE) stars = models.IntegerField(validators=[MinValueValidator(1),MaxValueValidator(5)], blank=True, null=True) comment = models.TextField(blank=True,null=True) ''' Views Code ''' class ProductListView(ListView): model = Products template_name = 'products.html' context_object_name ='Products' class ProductDetailView(LoginRequiredMixin,DetailView): login_url = '/accounts/login' model = Products # Using this function I want to take the rating and comment, but how can I access the cuurent object for which the comment and rating is being send by the user. def review(request,slug): star=request.POST.get('rating') comment=request.POST.get('comment') user = request.user productId = request.POST.get('productsid') # How to get the Product product = Products.objects.get(id=productId) review = Rating(product=product,user=user,stars=star,comment=comment) review.save() return redirect('/') # Urls code urlpatterns = [ path('',views.home,name='Home'), path('products',ProductListView.as_view(),name='Products'), path('product/<int:pk>',ProductDetailView.as_view(),name='Product-Details'), path('contact',views.contact,name='Contact'), path('review',views.review,name='review') #Templates Code <form method="POST" action="review"> {% csrf_token %} <input type="hidden" id="rating-value" name="rating"> <textarea style="margin-top:5px;" class="form-control" rows="3" id="comment" placeholder="Enter your review" name="comment"></textarea> <button type="submit" style="margin-top:10px;margin-left:5px;" class="btn btn-lg btn-success">Submit</button> </form> How to fetch the current object from the deatailed view page in the review function? I have added the code here. In Product detailed view page it is rendering the page through … -
Django, javascript, - Image slider Not looping through images which are in database
I am not familiar with js and a beginner altogether. I have a django formset through which I can upload upto 5 images at a time along with a blog post. I have 2 such posts with images to loop through in my homepage. The problem is slider isn't working for both posts at the same time rather it works for 1 post with images at a time and after that only, the second post slider works. Also it works well with the detail page as only a single post with images are there. Please have a look at this code which I got from a website. homepage.html <div class="slideshow-container"> {% for p in post.postimage_set.all %} <div class="mySlides"> <a href="{% url 'posts:detail_post' post.slug %}" ><img class="" style="content: center" height="400" width="400" src="{{ p.image.url }}"></a> </div> <!-- Next and previous buttons --> <a class="prev" onclick="plusSlides(-1)">&#10094;</a> <a class="next" onclick="plusSlides(1)">&#10095;</a> {% endfor %} </div> css .slideshow-container { max-width: 1000px; position: relative; margin: auto; } /* Next & previous buttons */ .prev, .next { cursor: pointer; position: absolute; top: 50%; width: auto; margin-top: -22px; padding: 16px; color: white; font-weight: bold; font-size: 18px; transition: 0.6s ease; border-radius: 0 3px 3px 0; user-select: none; } /* Position … -
Django-Channels/Daphne, incorrect subprotocol response returned
I am using django with django-channels for websocket support, served by daphne. Apparently, a common hack for authenticating websockets with token authentication is to put the token in the subprotocol argument of the websocket connection. I've done this, with the following AuthMiddleware: @database_sync_to_async def validate_token(token): auth = TokenAuthentication() return auth.authenticate_credentials(token.encode("utf-8")) @database_sync_to_async def close_connections(): close_old_connections() class WebsocketTokenAuthMiddleware: def __init__(self, inner): self.inner = inner def __call__(self, scope): close_connections() try: token = scope["subprotocols"][0] scope["user"] = validate_token(token) return self.inner(scope) except Exception: pass The consumer just checks whether or not there is a user in the scope, and calls await self.accept() if there is. This works fine on Firefox, but on Chrome, errors in the browser with 'Sent non-empty 'Sec-WebSocket-Protocol' but no response was received'. I am aware the chrome is stricter on these things, which presumably is why it works in firefox. -
How to enable auto-logout after some particular amount of time the user is idle using JWT in django
I am using JWT token for authorization and right now i have set the auto-logout function to be called after 15 minutes, no matter if the user is active or inactive. But i want the user to be logged out only after being idle for 15 minutes. How could I do that using JWT? -
Filtering to search for items in database
filters.py import django_filters from .models import * class ProductFilter(django_filters.FilterSet): class Meta: model=Product fields=['name',] Product class in models.py class Product(models.Model): name = models.CharField(max_length=200) price = models.FloatField() digital = models.BooleanField(default=False,null=True, blank=True) image=models.ImageField(null=True, blank=True) description=models.CharField(max_length=400, default='SOME STRING', null=True) OrderItem class in models.py class OrderItem(models.Model): product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True) order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True) quantity = models.IntegerField(default=0, null=True, blank=True) date_added = models.DateTimeField(auto_now_add=True) views.py def store(request): if request.user.is_authenticated: customer = request.user.customer # Returns a tuple of (object, created), # where object is the retrieved or created object and # created is a boolean specifying whether a new object was created. order, created = Order.objects.get_or_create(customer=customer, complete=False) items = order.orderitem_set.all() cartItems=order.get_cart_items else: #Create empty cart for now for non-logged in user items = [] order = {'get_cart_total':0, 'get_cart_items':0} cartItems=order['get_cart_items'] products = Product.objects.all() myFilter=ProductFilter(request.GET, queryset=items) items=myFilter.qs context = {'products':products, 'cartItems': cartItems, 'myFilter': myFilter} return render(request, 'store/store.html', context) templates file (main.html) <form class="form-inline mr-auto my-lg-0" method="get"> <input class="form-control mr-sm-2" style="width:1000px; height:38px;" type="text" placeholder="Search for items" aria-label="Search"> {{myFilter.form}} <button class="btn btn-outline-warning btn-rounded btn-sm my-0" style="width:80px; height:38px" type="submit">Search</button> </form> FieldError at / Cannot resolve keyword 'name' into field. Choices are: date_added, id, order, order_id, product, product_id, quantity Request Method: GET Request URL: http://127.0.0.1:8000/?name=Fifa+20 Django Version: 2.2 Exception Type: FieldError Exception … -
Keep exception count according to time in python
I'm trying to convert my list into a particular format(expected output), but I'm getting a problem. Here I'm trying to order exceptions according to a given time and in lexicographical order. My output: 21:15-21:30 IllegalAgrumentsException 1, 23:45-00:00 IllegalAgrumentsException 3, 01:00-01:15 IllegalAgrumentsException 0, 01:45-02:00 IllegalAgrumentsException 3, 02:00-02:15 IllegalAgrumentsException 0, 03:00-03:15 IllegalAgrumentsException 0, 21:15-21:30 NullPointerException 1, 21:15-21:30 NullPointerException 1, 22:15-22:30 NullPointerException 1, 23:00-23:15 NullPointerException 0, 23:30-23:45 NullPointerException 2, 23:30-23:45 NullPointerException 2, 00:30-00:45 NullPointerException 2, 01:30-01:45 NullPointerException 2, 02:30-02:45 NullPointerException 2, 22:00-22:15 UserNotFoundException 0, 22:30-22:45 UserNotFoundException 2, 22:30-22:45 UserNotFoundException 2, 22:30-22:45 UserNotFoundException 2, 22:45-23:00 UserNotFoundException 3, 23:15-23:30 UserNotFoundException 1, 00:00-00:15 UserNotFoundException 0, 00:45-01:00 UserNotFoundException 3, 01:15-01:30 UserNotFoundException 1, 02:15-02:30 UserNotFoundException 1, Expected Output : 21:15-21:30 IllegalAgrumentsException 1, 21:15-21:30 NullPointerException 2, 22:00-22:15 UserNotFoundException 1, 22:15-22:30 NullPointerException 1, 22:30-22:45 UserNotFoundException 3, 22:45-23:00 UserNotFoundException 1, 23:00-23:15 NullPointerException 1, 23:15-23:30 UserNotFoundException 1, 23:30-23:45 NullPointerException 2, 23:45-00:00 IllegalAgrumentsException 1, 00:00-00:15 UserNotFoundException 1, 00:30-00:45 NullPointerException 1, 00:45-01:00 UserNotFoundException 1, 01:00-01:15 IllegalAgrumentsException 1, 01:15-01:30 UserNotFoundException 1, 01:30-01:45 NullPointerException 1, 01:45-02:00 IllegalAgrumentsException 1, 02:00-02:15 IllegalAgrumentsException 1, 02:15-02:30 UserNotFoundException 1, 02:30-02:45 NullPointerException 1, 03:00-03:15 IllegalAgrumentsException 1 I got my output by performing a particular algorithm which is:(my approach) data = {'minute': 27, 'hour': 21, 'second': 12, 'data': 'IllegalAgrumentsException'} {'minute': 57, 'hour': 23, … -
How to sort a queryset of different models in Wagtail/Django?
I have a Wagtail site and I'm making a listing page for a few different Page types/Content types. I filter by a snippet field first: def highlights_list(category='Highlight'): tag = ContentCategory.objects.get(name=category) highlights = Page.objects.filter( Q(event__categories=tag)| Q(newspage__categories=tag)| Q(contentpage__categories=tag)).live() return highlights.order_by('-last_published_at') In Wagtail all content types inherit from the base Page class which makes creating a queryset with all the content types I want really easy. But I can't work out how to sort nicely. Sorting by last_published_at is fine for NewsPage and ContentPage but not for Event where I'd like to sort by the DateTimeField for the event. I thought about making a @property on all the models called sort_date which uses the datetime field specific to each model that I'd like to sort on, but that just doesn't work. Any suggestions are very welcome! -
Confusion with Foreign key and manyToManyField in Django
I was creating library system with Django and also I was designing database. So, I have this logic that one student can have many books but one can belong to one student. Thus, student table needs to have foreign key of book table. But, it restricts us to choose ONLY ONE book Right? But I want to allow for student to choose many books thus I need to use ManyToManyField(). But, if I use that my one-to-many logic turns into many-to-many. Is what I am doing correct? Again, logically, one-to-many relationship is correct BUT it restricts us to choose ONLY one book. To solve this problem, we can use ManyToManyField() but the logic turns into many-to-many which will mean student can have many books but one book can belong to many student which is wrong since book can belong to one student. -
Django admin TabularInline autocomplete filed
I have two models in the Django app and ManyToMany relationships between them. Now I would like to add an autocomplete field on inlines of one of them. How to do this? Is there an external library to do this? -
Django 2.2 PermissionRequiredMixin add message to dispatch / missing get_permission_required error
it drives me nuts that I cannot solve that (I bet easy) problem. Django 2.2, Python 3.8.2 I want to add a error message, if you dont have any permission to call the ListView. view.py class ProjectListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): template_name = "list_projects.html" permission_required = "project.view_all_projects" raise_exception = True def get_queryset(self): queryset = Project.objects.all() ... return queryset My 403.html {% if messages %} <ul class="messages" style="list-style: none;"> {% for message in messages %} <li class="{{ message.tags }}"> {{ message }} </li> {% endfor %} </ul> {% endif %} I found this website (http://ccbv.co.uk/projects/Django/2.2/django.contrib.auth.mixins/PermissionRequiredMixin/) and my idea was to override the dispatch function: def dispatch(self, request, *args, **kwargs): if not self.has_permission(): messages.error(self.request, 'Error: 123') return self.handle_no_permission() return super().dispatch() But then I get a "'ProjectListView' object has no attribute 'get_permission_required'". According to this website, the function exists. I'm missing something? Another idea was to override the handle_no_permission function, but this wont be executed: def handle_no_permission(self): messages.error(self.request, 'You have no permission') return super().handle_no_permission() console Traceback (most recent call last): File "/home/pyt/Projects/env/project/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/pyt/Projects/env/project/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/pyt/Projects/env/project/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/pyt/Projects/env/project/lib/python3.8/site-packages/django/views/generic/base.py", line 71, in … -
Django: how to define form in class based views? -> error (init() missing 1 required positional argument) when using form_class
I have already posted (see link below) to 'valid' my ER diagram. I try to develop a form based on 'trought' model with nested inlineformset. It works when I define fields in the UtilisateurCreateView class but I want to customize the 'trought' parent's form to be able to: set initial pro_ide value with value send by GET hidden this pro_ide field customize uti_ide field label So I define a UtilisateurProjetCreateForm based on the 'throught' model like I'm used to do but I got an error: init() missing 1 required positional argument: 'request' moreover, as this form is based on 'throught' model, I am not sure I should define forms.ChoiceField... models.py class Projet(SafeDeleteModel): _safedelete_policy = SOFT_DELETE_CASCADE pro_ide = models.AutoField(primary_key = True) # utilisateurs = models.ManyToManyField(Utilisateur, through='UtilisateurProjet') pro_nom = models.IntegerField("Nom du projet") pro_log = models.CharField("Log utiisateur", max_length=20, null=True, blank=True) pro_dat = models.DateTimeField("Date log",auto_now_add=True) pro_act = models.IntegerField("Projet en cours ?", null=True, blank=True) class Meta: db_table = 'tbl_pro' verbose_name_plural = 'Projets' ordering = ['pro_ide'] permissions = [ ('can_add_project','Can add project'), ] def __str__(self): return f"{self.pro_nom}" class Utilisateur(SafeDeleteModel): _safedelete_policy = SOFT_DELETE_CASCADE uti_ide = models.AutoField(primary_key = True) # pro_ide = models.ForeignKey(Projet, on_delete = models.CASCADE) # related project projets = models.ManyToManyField(Projet, through='UtilisateurProjet') uti_nom = models.CharField("Nom", max_length=20) uti_pre … -
Why does AWS Beanstalk Give an Error for Django Version higher than 2.1
I tried to deploy a sample app to EB with Django version 2.1 and it works as expected. When I tried THE LTS version 2.2 or django version 3.0.5, when I go to the web app, it returns a 500 error. I went to the logs and it shows this error RuntimeError: populate() isn't reentrant. But this error occurs only when I upgraded the Django version to higher than 2.1. The weird thing is that I already have an application running on EB from before with version 3.0.5 and it is working perfectly fine. But when I create a new app with that version, it gives the error above, but not if the Django version is 2.1 which is also insecure. Does anyone know why that error occurs with django 2.2 and higher? -
How to read python environment variables in shell script [closed]
I am trying to get environment variable in my sh file. #!/bin/bash ENVIROMENT_VAR=$(python -c "import os"; "os.environ['DJANGO_SETTINGS_MODULE']") FILENAME=$(readlink -f "$0") BASE_DIR=$(dirname $(dirname $(dirname "$FILENAME"))) echo $ENVIROMENT_VAR i am getting following error. os.environ['DJANGO_SETTINGS_MODULE']: not found -
django.db.utils.ProgrammingError: relation "<name>" does not exist
I am using django-organisations to have multiple user-accounts in multiple organisations. However, it is single-schema architecture. In order to make it separate-schema architecture, I am using django-tenants. I have following code:- models.py from django.contrib.auth.models import Permission from django.db import models from django_tenants.models import TenantMixin, DomainMixin from organizations.abstract import ( AbstractOrganization, AbstractOrganizationOwner, AbstractOrganizationUser, ) class Vendor(AbstractOrganization, TenantMixin): street_address = models.CharField(max_length=100, default="") city = models.CharField(max_length=100, default="") account = models.ForeignKey( "accounts.Account", on_delete=models.CASCADE, related_name="vendors" ) def __str__(self): return self.schema_name class VendorUser(AbstractOrganizationUser): user_type = models.CharField(max_length=1, default="") permissions = models.ManyToManyField(Permission, blank=True) class VendorOwner(AbstractOrganizationOwner, DomainMixin): pass settings.py import os # Django settings for conf project. settings_dir = os.path.dirname(__file__) PROJECT_ROOT = os.path.abspath(os.path.dirname(settings_dir)) DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { "default": { 'ENGINE': 'django_tenants.postgresql_backend', 'NAME': '**', 'USER': '**', 'PASSWORD': '**', 'HOST': '**', 'PORT': '**' } } # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # On Unix systems, a value of None will cause Django to use the same # timezone as the operating system. # If running in a Windows environment this must be set to the …