Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I have a OneToOne relationship between two objects of the same class in a Django app. Is it possible to enforce the uniqueness of this relationship?
I have the following in my app: class University(models.Model): ... sister_university = models.OneToOneField('self', related_name = 'university_sister_university', blank=True, null=True, on_delete=models.SET_NULL) I only want a university to be related to one other university in both directions of that relationship. For example, in the database, if I select university A as the sister_university of university B, I only want to be allowed to select university B as the sister_university under university A also. However, as it is, that second relationship is not enforced. For example: Right now, under the Django Admin site, if I first select university A as the sister university of university B, I am still able to select any other university as the sister university of the university A object. I’m not constrained to only selecting university B. Is it possible to enforce that uniqueness at the database level? Is there a better way of accomplishing what I’m trying to do? -
DjangoCMS show menu on wrong language
I have site https://www.mobydisc.de/. It have DE and EN versions. When i go to the site from browser, all content of site is on DE. When i check site with https://www.google.com/webmasters/tools/googlebot-fetch-details, content is on DE, but menu on EN. How i can fix it? Settings LANGUAGE_CODE = 'de' TIME_ZONE = 'Europe/Berlin' USE_I18N = True USE_L10N = True USE_TZ = True CMS_LANGUAGES = { 1: [ { 'code': 'de', 'name': gettext('Deutsch'), 'fallbacks': ['en'], 'public': True, }, { 'code': 'en', 'name': gettext('English'), 'fallbacks': ['de'], 'public': True, 'hide_untranslated': True, 'redirect_on_fallback':False, }, ], 'default': { 'fallbacks': ['de'], 'redirect_on_fallback':True, 'public': True, 'hide_untranslated': False, } } -
Django-Haystack-Whoosh is giving no results
I'm trying to use Haystack-Whoosh for search in a Django application. I've implemented code same as mentioned in documentation page: django-haystack documentaation but still it is not working no search results were filtered. Here is my code: models.py from django.db import models from datetime import datetime class Newcar(models.Model): car_name = models.CharField(max_length=50) carmodel = models.CharField(max_length=50) car_logo = models.CharField(max_length=1000) pub_date = models.DateTimeField(default=datetime.now()) def __str__(self): return self .car_name + '-' + self .carmodel search_indexes.py import datetime from haystack import indexes from car.models import Newcar class NewcarIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) car_name = indexes.CharField(model_attr='car_name') carmodel = indexes.CharField(model_attr='carmodel') pub_date = indexes.DateTimeField(model_attr='pub_date') def get_model(self): return Newcar def index_queryset(self, using=None): return self.get_model().objects.all() newcar_text.txt {{ object.car_name }} {{ object.carmodel }} search.html {% block content %} <h2>Search</h2> <form method="get" action="."> <table> {{ form.as_table }} <tr> <td>&nbsp;</td> <td> <input type="submit" value="Search"> </td> </tr> </table> {% if query %} <h3>Results</h3> {% for result in page.object_list %} <p> <a href="{{ result.object.get_absolute_url }}">{{ result.object.car_name }}</a> </p> {% empty %} <p>No results found.</p> {% endfor %} {% if page.has_previous or page.has_next %} <div> {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %} | {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% … -
Changing the language through "/i18n/setlang/" ajax POST is not doing anything on Firefox
My backend uses Django and my front end is done with ReactJS. When users change their profile's language, I perform a POST ajax call to /i18n/setlang/ with the data object {language: [language_code]} and refresh the page. I simply have this ajax call to change the language, a bunch of .po/.mo files with the translations and I am using gettext() to translate the lines in JS. This works perfectly on Chrome but is completely ignored on Firefox and no translation is done. Any idea why? My middleware contains the django.middleware.locale.LocaleMiddleware and my LOCALE_PATH is set as such: MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] LOCALE_PATHS = [ os.path.join(BASE_DIR, 'locale') ] -
Django - Sum of different Currencies
we are currently building a cryptocurrency market (university project) Each user has different cryptocurrencies in his "Wallet" The wallet should show the sum (+ and - transactions) for each of the different cryptocurrencies. For the moment we are only able to render a list which doesn't group the different currencies (those who have the same name) We tried the sum and annotate functions. By doing so we aren't able to display the currency name. We get only the currency id Here is our models file class Currency(models.Model): currency_name = models.CharField(max_length=40, unique=True) symbol = models.ImageField(blank=True) ticker = models.CharField(max_length=10) created_at = models.DateTimeField(auto_now_add = True, null=True) class Transaction(models.Model): listing_id = models.ForeignKey(Listing, on_delete=models.CASCADE, null=True, blank=True) created_at = models.DateTimeField(auto_now_add = True) exchange_amount = models.IntegerField(null=True) user_debit = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_id_debit', null=True) user_credit = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_id_credit', null=True) currency_id = models.ForeignKey(Currency, on_delete=models.CASCADE, null=True) And our views.py #profile page @login_required def profile(request): wallet = Transaction.objects.filter(Q(user_credit=request.user) | Q(user_debit=request.user)).order_by('-created_at') transactions = Transaction.objects.filter(Q(user_credit=request.user) | Q(user_debit=request.user)).order_by('-created_at')[:10] listings = Listing.objects.filter(user=request.user).order_by('-created_at')[:10] args = {'wallets': wallet, 'transactions': transactions, 'listings': listings} return render(request, 'profile.html', args) And a screenshot of the concerned page enter image description here -
Show manytomany field in Django?
I am new to Django framework. I really appreciate if anyone could help. I have Employee and Project tables in models.py That is ManytoMany relationship On index.html I display the table that show all Project fields including (project_name, project_description). When I click on project description it will link me to other page which is emp_detail.html (I were successful to this step) On emp_detail.html I want to display pro_description which I clicked on at the previous step along with employee fields including (first_name, last_name) who work for that project. (I failed at this step) I really appreciate the helps!! -
cetos httpd Django sendEmail error
emmmm, it's fine to send email using the method from django.core.mail by python manage.py shell . However, after deploying in httpd 2.4 , i cant get the email, the error log is following: /var/log/httpd/error_log: [Mon May 14 23:36:54.915095 2018] [:error] [pid 12098] Sending mail to 1165527916@qq.com The environment is centos + httpd2.4 + python2.7 + django . And the selinux is disabled. Anyone who can give me a hand .Thx. -
Django applications sharing databases on Heroku: set 'shared' database once for all
I have several Django applications and they need to share one database on Heroku. I may specify the shared database on each statement that need to access it, for example: from account.models import User if DEBUG: # Running locally users = User.objects.all() # 'default' DB else: # Running on Heroku users = User.objects.using('shared').all() # 'shared' DB I have two questions: 1) Specifying the shared database on every statement is really tedious. Is it possible to set the shared database once for all (maybe in setting.py)? For example: from account.models import User if not DEBUG: # Running on Heroku User = User.objects.using('share') # This is hypothetical!! users = User.objects.all() 2) How do I set the 'shared' DB for a foreign key. For example: from account.models import User class Article(models.Model): author = models.ForeignKey(User) # How to set 'User' to come from 'shared' DB? -
Django get objects of objects
I have 3 models: class Project(models.Model): ... class Group(models.Model): project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name = "groups") class Word(models.Model): group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, related_name = "words") I want to get all words that are in a project. How do I do this? -
Django global variable to store immutable object
I'm trying to set up python-telegram-bot library in webhook mode with Django. That should work as follows: on Django startup, I do some initial setting of python-telegram-bot and get a dispatcher object as a result. Django listens to /telegram_hook url and receives updates from Telegram servers. What I want to do next is to pass the updates to the process_update method of the dispatcher created on startup. It contains all the parsing logic and invokes callbacks specified during setup. The problem is that the dispatcher object needs to be saved globally. I know that global states are evil but that's not really a global state because the dispatcher is immutable. However, I still don't know where to put it and how to ensure that it will be visible to all threads after setup phase is finished. So the question is how do I properly save the dispatcher after setup to invoke it from Django's viewset? P.S. I know that I could use a built-in web server or use polling or whatever. However, I have reasons to use Django and I anyway would like to know how to deal with cases like that because it's not the only situation I can … -
Django (Like/dislike button)
I am trying to implement like/ dislike button in django but not getting the functionality. The button is there but when I click on it, nothing is happening and also I cannot see the total likes. Can someone please help me with this ?enter image description here url views model -
Modify form-group DIV tag in Django crispy-forms
Django crispy-forms wraps every field in a structure like this: <div id="div_id_name" class="form-group"> <div class="controls "> <div class="input-group"> <input ... > </div> </div> </div> How can I modify the form-group div tag? I need to add a class (ideally) or at least an id. -
How to use bootstrap modal with django?
I'm trying to create a list of items and each item has a button to click and update that item I'm trying to use bootstrap modal for update I can get it working the problem is when I hit the update button it does not work because is not passing the pk to my url, any ideas to solve this problem ? This is my view class ResearcherExperienceListView(LoginRequiredMixin, ListView): model = Researcher template_name = 'researcher/researcher_list.html' def get_queryset(self): queryset = super(ResearcherExperienceListView, self).get_queryset() queryset = Researcher.objects.get(pk=self.kwargs['pk']) print(self.kwargs) return queryset this is my template for my ListView {% extends "base.html" %} {% block content %} <div class="container"> <div class="row" style="padding-top: 5%"> <div class="col-lg-10 col-lg-offset-1 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 "> <h1 class="title text-center">Experiencia em Areas de conhecimento</h1> <table class="table table-hover"> <thead> <tr> <th>Area de Conhecimento</th> <th>Ações</th> </tr> </thead> <tbody> {% for item in object_list.experience.all %} <tr> <td> {{item}} </td> <td> <a data-toggle="modal" href="{% url 'researcher_experience_update' pk=item.pk %}" data-target="#{{item.pk}}" data-tooltip> <i class="fa fa-edit fa-2x"></i> </a> </td> </tr> <div class="modal fade " id="{{item.pk}}" tabindex="-1" role="dialog"> {% include "researcher/experiencetime_form.html" %} </div> {% endfor %} </tbody> </table> </div> </div> </div> {% endblock content %} My view for update class ResearcherExperienceUpdateView(LoginRequiredMixin, UpdateView): model = ExperienceTime form_class = ExpirienceTimeForm This … -
Djaongo REST Framework - queryset filter only for authenticated user
I'm new to Django REST Framework. I think I have gone messed up in it as sometimes it feels like DRF is easy to understand but later it got messed up. I have a contacts application. contacts/models.py class Contact(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100, blank=True, null=True) date_of_birth = models.DateField(blank=True, null=True) class ContactEmail(models.Model): contact = models.ForeignKey(Contact, on_delete=models.CASCADE) email = models.EmailField() class ContactPhoneNumber(models.Model): contact = models.ForeignKey(Contact, on_delete=models.CASCADE) phone = models.CharField(max_length=100) Each contact is related some authenticated user. contacts/serializers.py class ContactPhoneNumberSerializer(serializers.ModelSerializer): class Meta: model = ContactPhoneNumber fields = ('id', 'phone') class ContactEmailSerializer(serializers.ModelSerializer): class Meta: model = ContactEmail fields = ('id', 'email') class ContactSerializer(serializers.HyperlinkedModelSerializer): phone_numbers = ContactPhoneNumberSerializer(source='contactphonenumber_set', many=True) emails = ContactEmailSerializer(source='contactemail_set', many=True) class Meta: model = Contact fields = ('url', 'id', 'first_name', 'last_name', 'date_of_birth', 'phone_numbers', 'emails') and contacts/views.py class ContactViewSet(viewsets.ModelViewSet): queryset = Contact.objects.all() serializer_class = ContactSerializer permission_classes = (IsAuthenticated, AdminAuthenticationPermission,) def perform_create(self, serializer): serializer.save(user_id=self.request.user) as far till here, I followed the doc of Django REST Framework but it displays all contacts instead of showing only user's contacts. To achieve that, I added get_queryset() class ContactViewSet(viewsets.ModelViewSet): # queryset = Contact.objects.all() ... def get_queryset(self): return Contact.objects.filter(user=self.request.user) ... But it started giving error as assert queryset is not None, '`base_name` argument not … -
Django: Clearing request.session between forms causes csrf token error?
I am facing a very specific problem that I've narrowed down to a particular reason, and I am afraid I may simply be misunderstanding or wrongly applying my logic here. Django users will know that CSRF protection is handled by a django middleware and that each form used in the project should be followed by a {% csrf_token %} tag. My project contains an app that serves users data based on their OAuth2-authenticated sessions, for which I then save/retain some session-specific REST data. As you can probably guess, I have to clear the session cache quite often in cases of new users, or some particular parameters changing in terms of the current user's session. In order to do this, I retain some of the values from the request.session dictionary and then clear the session like so remember_dictionary = { '''some values that I wish to remember''' } request.session.clear() for key, value in remember_dictionary.items(): if value: request.session[key] = value If this function has been called in the event of the user having two forms up on the website concurrently, the older form will throw a Forbidden Error/csrf token missing. I understand that the request.session.clear() probably has something to do with this, … -
django.db.utils.ProgrammingError: can't adapt type after migrating from sqlite to postgresql using ModelChoiceFilter
I'm using django-filters (https://github.com/carltongibson/django-filter) to perform a query to my DB. I'm using ModelChoiceFilter from django_filters.filterset to filter based on some ForeignKeyFields. This is how my implementation looks like: In my model: class FiltrosProducto(django_filters.FilterSet): marca = django_filters.ModelChoiceFilter( label='', name='marca', lookup_expr='nombre__iexact', queryset=Marca.objects.all(), empty_label='Marca', widget=forms.Select(attrs={'class': 'form form-control'}) ) nombre = django_filters.CharFilter( label='', name='nombre', lookup_expr='icontains', widget=forms.TextInput( attrs={ 'class': 'form form-control', 'placeholder': 'Producto' } ) ) familia_1 = django_filters.ModelChoiceFilter( label='', name='familia_1', lookup_expr='nombre__iexact', queryset=Familia.objects.filter(nivel=1) .exclude(nombre='Servicios'), empty_label='Categoría', widget=forms.Select(attrs={'class': 'form form-control'}) ) familia_2 = django_filters.ModelChoiceFilter( label='', name='familia_2', lookup_expr='nombre__iexact', queryset=Familia.objects.filter(nivel=2), empty_label='Sub-Categoría 1', widget=forms.Select(attrs={'class': 'form form-control'}) ) familia_3 = django_filters.ModelChoiceFilter( label='', name='familia_3', lookup_expr='nombre__iexact', queryset=Familia.objects.filter(nivel=3), empty_label='Sub-Categoría 2', widget=forms.Select(attrs={'class': 'form form-control'}) ) class Meta: model = Producto fields = ['marca', 'nombre', 'familia_1', 'familia_2', 'familia_3'] In my view: productos = FiltrosProducto( request.GET, queryset=Producto.objects.filter( activo=True ).exclude( familia_1__nombre='Servicios' ) ) and this is a snippet of the traceback for the error that i'm getting: db_exc_type <class 'psycopg2.ProgrammingError'> dj_exc_type <class 'django.db.utils.ProgrammingError'> dj_exc_value ProgrammingError("can't adapt type 'Marca'",) exc_type <class 'psycopg2.ProgrammingError'> exc_value ProgrammingError("can't adapt type 'Marca'",) self <django.db.utils.DatabaseErrorWrapper object at 0x7f2d50961390> traceback <traceback object at 0x7f2d509a3b88> Same code worked fine with sqlite. Any ideas ? :/ -
How can I use mysql and django in Bitnami?
I am using bitnami with aws to deploy my django app. I have made the necessary changes to the settings.py with my credentials. I have already created the database but after I run this command python manage.py migrate it shows error django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)") -
django celery and asyncio - loop argument must agree with Future approx every 3 mins
Im using django celery and celery beat to run periodic tasks. I run a task every one minute to get some data via SNMP. My function uses asyncio as per the below. I have put a check in the code to check if the loop is closed and to create a new one. but what seems to be happening is every few tasks, I get an failure and in the Django-tasks-results db I have the below traceback. there seems to be a failure around every 3 minutes Error: Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 374, in trace_task R = retval = fun(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/celery/app/trace.py", line 629, in __protected_call__ return self.run(*args, **kwargs) File "/itapp/itapp/monitoring/tasks.py", line 32, in link_data return get_link_data() File "/itapp/itapp/monitoring/jobs/link_monitoring.py", line 209, in get_link_data done, pending = loop.run_until_complete(asyncio.wait(tasks)) File "/usr/local/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete return future.result() File "/usr/local/lib/python3.6/asyncio/tasks.py", line 311, in wait fs = {ensure_future(f, loop=loop) for f in set(fs)} File "/usr/local/lib/python3.6/asyncio/tasks.py", line 311, in <setcomp> fs = {ensure_future(f, loop=loop) for f in set(fs)} File "/usr/local/lib/python3.6/asyncio/tasks.py", line 514, in ensure_future raise ValueError('loop argument must agree with Future') ValueError: loop argument must agree with Future Function: async def retrieve_data(link): poll_interval = 60 results = [] # credentials: … -
Complex query annotation for each distinct
In PurchaseOrder list view I would like to display the total quantity grouped by each distinct unit. I'm using the following models and function but there's a database hit for each object in the list. class PurchaseOrder(models.Model): lines = models.ManyToManyField( Product, blank=True, through='PurchaseOrderLine' related_name='%(class)s_line') def get_quantity_by_unit(self): return PurchaseOrderLine.objects.filter(purchase_order=self).values( 'unit__abbreviation').annotate(sum=Sum('quantity')) class PurchaseOrderLine(models.Model): purchase_order = models.ForeignKey(PurchaseOrder) quantity = models.DecimalField() unit = models.ForeignKey(Unit) Can this be achieved with django orm? The following gets the total quantity but not for each distinct unit: query = PurchaseOrder.objects.filter(date__gte=cutoff_date).annotate( total=Sum('purchaseorderline_order__quantity')) The following throws ValueError: Prefetch querysets cannot use values(). queryset = PurchaseOrderLine.objects.values( 'unit').order_by('unit').annotate(total=Sum('quantity')) query = PurchaseOrder.objects.filter(date__gte=cutoff_date).prefetch_related( Prefetch('purchaseorderline_order', queryset=queryset, to_attr='totals')) -
How can i pass custom object(choice field) to form using Django
I am new to django, I created my custom user(auth_user) model. I need to set choice values in title field according to my object (render choice value to template) I have two models Title, User like this: class Title(models.Model): value = models.CharField(max_length=100, null=True, blank=True) def __str__(self): return self.value class Meta: db_table = 'title' class User(AbstractUser): title = models.ForeignKey(Title, on_delete=models.CASCADE, null=True, blank=True) class Meta: db_table = 'user' Here i have ForeignKey title field and User default fields first_name, last_name, email,password My forms.py: class StudentNewRegistrationForm(forms.ModelForm): title = forms.CharField(required=True) username = forms.CharField(required=True) first_name = forms.CharField(required=True) last_name = forms.CharField(required=True) email = forms.EmailField(required=True) password1 = forms.CharField(required=True) password2 = forms.CharField(required=True) def __init__(self, *args, **kwargs): super(StudentNewRegistrationForm, self).__init__(*args, **kwargs) self.fields['title'] = forms.ModelChoiceField(queryset=Title.objects.all(), empty_label='Choose a title',required=False) class Meta: model = User fields = ['title','username', 'first_name', 'last_name','email' 'password1', 'password2'] def save(self, commit=True): user = super(StudentNewRegistrationForm, self).save(commit=False) user.username = self.cleaned_data['username'] user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] user.email = self.cleaned_data['email'] user.title = self.cleaned_data['title'] user.password1 = user.set_password(self.cleaned_data['password1']) user.password2 = user.set_password(self.cleaned_data['password2']) if commit: user.save() return user Here i have api response like below: {"candidate":{"firstname":"Testuser","lastname":"test","salutation":10000,"email":"testing@gmail.com","username":"test"}} I am creating new user object like below and i tried to retain values to my form, here issue was text fields are retain but choice fields are not rendering … -
Django model queryset using related names and managers
I have 4 models - class Group(models.model): group_id = models.CharField(max_length=10) name = models.CharField(max_length=20) class User(models.model): user_id = models.CharField(max_length=10) grp = models.ForeignKey(Group, null=True, blank=True) user_name = models.CharField(max_length=50) contact_no = models.CharField(max_length=20) class DesigType(models.model): desig_name = models.CharField(max_length=10) class Designation(models.model): user = models.ForeignKey(User, null=True, blank=True, related_name='desigs') desig_type = models.ForeignKey(DesigType, null=True, blank=True, related_name='desigs') Group model holds groups of users. User holds records for each individual user. DesigType has information about "type of designation", like maybe manager, team lead etc. Designation stores the exact designation - for example, for manager DesigType, Designation might have project manager or account manager; similarly, for team lead DesigType, Designation might have front-end lead or back-end lead. The UI currently shows a list of users under a group. I want to implement a search functionality according to desig_name. The UI sends me the group_id and the text entered by the end-user in the search box, and I have to return only those Users which have the corresponding desig_name. I have already done the above, by using a property to return a list of desig_names that a User has and checking whether the user input exists in the list. This is a property under User - @cached_property def desig_types(self): desig_types = [] … -
django ApiView login returns 404
I am having problems with my login API view. When trying to login I get a POST 404 but I know the url path is correct because if I put a simple GET request in the view it returns data. There are still some rough parts of my code but I thought this would work. login.py from django.contrib.auth import authenticate from django.shortcuts import get_object_or_404 from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status from apiV1.v1.accounts.models.user import User from apiV1.v1.accounts.serializers.user import UserSerializerLogin # login class LoginView(APIView): authentication_classes = () permission_classes = () @staticmethod def post(request): user = get_object_or_404(User, email=request.data.get('email')) user = authenticate(username=user.email, password=request.data.get('password')) if user: serializer = UserSerializerLogin(user) return Response(serializer.data) return Response(status=status.HTTP_400_BAD_REQUEST) serializers.py class UserSerializerLogin(UserSerializer): token = serializers.SerializerMethodField() @staticmethod def get_token(user): """ Get or create token """ token, created = Token.objects.get_or_create(user=user) return token.key class Meta: model = User fields = ('id', 'email', 'first_name', 'last_name', 'profile', 'role', 'token') -
Django auto refresh cache
Does django provide a way to automatically refresh caching objects. I am working to define lot of logic using low level cache functions that it can easily be automated by the framework : Save cache when object is requested. Delete related cache when model changes. What is the cleaner way to achieve this ? -
Django one to many (0..4) relationship
I would like to know if there is someway of doing a relationship 0..4. I mean, 1 user has 0 to 4 devices, and 1 device belongs to a user. How I can represent that? That 0..4 can be represented, or should be controlled on my program logic? -
How to solve " Operation error unable to open database file"?
I am using bitnami for hosting my django web app which uses apache. Every time I login into my django admin panel it shows Django Version: 1.11 Exception Type: OperationalError Exception Value: unable to open database file Exception Location: /opt/bitnami/apps/django/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 328 I cant handle anything which involved my db.sqlite3. My db.sqlite3 permissions are 775 with group=daemon and owner= bitnami. This is my settings.py snippet DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }