Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to have Django *not* parse "{{variable}}" when using Jsrender?
I am building a Django template which will use jsrender in order to build out dynamic Javascript templates for html code. However, I find that when I put a Jsrender template in my code, Django flips out because Django parses anything between {{ and }} as a variable, and Jsrender uses this for its own variables. For instance, a template in Jsrender might look like: <script id="headerTemplate" type="text/x-jsrender"> <h1>{{:label}}</h1> </script> Django sees {{:label}} and tries to parse it, which leads to an error. Is there a Django block I can invoke which would make Django not parse any text within it? Or otherwise to escape a { character? -
Django : How should I correct this Form to display the data of the models in a dropdown list
I am Newbee in Django. I want to create a Form for a dropdown list. The Dropdown list should show different choices depending on User and the Models. So to get the data that I want to display in the dropdown list. I start to get the user ID. Then from the User ID, I get the list of ID clients that this user has access in the model "TblAadJntGroup". Finally I identify the client list by getting the correlation of this list of ID in the model "TblAadGroups". I write this form from the models that are listen below. It gets well the "id_client_list", but I do not know how to add it in the "forms.ChoiceField" after the init method. What should I change or improve Forms.py class SelectClient(forms.ModelForm): def __init__(self, *args, **kwargs) : self.user = kwargs.pop('user') super(SelectClient, self).__init__(*args, **kwargs) id_client_list = TblAadJntGroup.objects.filter(id_aaduser=self.user.id).values_list('id_aadgroup', flat=True) id_client_list = list(id_client_list) self.fields['ID_Customer'].queryset = TblAadGroups.objects.all().filter(id__in=id_client_list) class Meta: model = UploadFiles fields = ['ID_Customer'] client_list = forms.ChoiceField() models.py class TblAadJntGroup(models.Model): id = models.AutoField(db_column='ID', primary_key=True) # Field name made lowercase. id_aadgroup = models.IntegerField(db_column='ID_AADGroup', blank=True, null=True) # Field name made lowercase. id_aaduser = models.IntegerField(db_column='ID_AADUser', blank=True, null=True) # Field name made lowercase. createdon = models.DateTimeField(db_column='CreatedOn', blank=True, null=True) # … -
processing image uploaded by createview in django
I am returning back to django after a while, and I am a bit confused on how I should go about processing images once they have been uploaded in createview class. So, I have this: class SomeModel(models.Model): full_name = models.CharField(max_length=200) email_simple = models.EmailField(max_length = 256) image = models.ImageField(upload_to='images') def __str__(self): return self.full_name class SomeModelForm(forms.ModelForm): """Form for the image model""" class Meta: model = FASModel fields = ('full_name', 'email_simple', 'image') <form role="form" action="{% url 'upload' %}" enctype="multipart/form-data" method="post">{% csrf_token %} {{ form.as_p }} <button type="submit">Upload</button> </form> It works fine as in uploads the image, but, before redirecing to say an upload done page, I would like to postprocess this image using custom logic (such as resizing using ffmpeg and processing it further). Which method within CreateView can allow me to do this? or is there a more efficient way to approach this problem? Thank you. -
Problem with related objects in REST Framework
I have a simple django application with the following models: class Product(models.Model): __metaclass__ = ABCMeta title = models.CharField(max_length=50) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) slug = models.SlugField(max_length=100, unique=True) price = models.IntegerField() is_published = models.BooleanField(default=True) @abstractmethod def __str__(self): pass @abstractmethod def get_absolute_url(self): pass class SupplyType(models.Model): title = models.CharField(max_length=10) slug = models.SlugField(max_length=100, unique=True) def __str__(self): return self.title def get_absolute_url(self): return reverse('supply_type_detail', kwargs={'slug': self.slug}) class Processor(Product): supply_type = models.ForeignKey(SupplyType, on_delete=models.CASCADE) cores_amount = models.IntegerField() threads_amount = models.IntegerField() technological_process = models.IntegerField() def __str__(self): return self.title def get_absolute_url(self): return reverse('processor_detail', kwargs={'slug': self.slug}) The corresponding serializers were written for them: class SupplyTypeSerializer(ModelSerializer): class Meta: model = SupplyType fields = '__all__' class ProcessorSerializer(ModelSerializer): class Meta: model = Processor fields = '__all__' depth = 1 The corresponding views were also written (I will give only the views of creation for an example): class ProcessorCreateAPIView(CreateAPIView): model = Processor serializer_class = ProcessorSerializer class SupplyTypeCreateAPIView(CreateAPIView): model = SupplyType serializer_class = SupplyTypeSerializer When I try to add "Supply Type" using POST request, it works successfully. However, when I try to add a processor like this: { "title": "Intel Pentium Gold G6400", "slug": "intel-pentium-gold-g6400", "price": 19690, "is_published" : true, "cores_amount": 2, "threads_amount": 4, "technological_process": 14, "supply_type": 1 } I get an error: django.db.utils.IntegrityError: null … -
how to display a pdf in django admin? instead of the link
models.py class Equipo(models.Model): CODIGO = models.CharField(primary_key=True, max_length=5 ) DESCRIPCION = models.CharField(max_length=50, default='') TITULO = models.FileField(upload_to = "Archivos/Titulos/", default='', blank=True) admin.py from django.contrib import admin from .models import Equipo class EquipoAdmin(admin.ModelAdmin): list_display = ('CODIGO', 'DESCRIPCION', 'TITULO') admin.site.register(Equipo, EquipoAdmin) I need to see something like this -
Why does django-wishlist require django-user-accounts dependency
How to I merge django-wishlist package with the user account. My head is doing in now. Worked on it for more than a day. https://github.com/dokterbob/django-wishlist https://github.com/pinax/django-user-accounts -
Permission error with Django logs in production
When trying to apply logging config to my Django project on the production server, the site returns a 502 gateway error and sudo journalctl -u gunicorn shows the following Permission denied: '/home/logs/MySite.log' error. The same config runs on the staging server and is working (using the same debug=false, gunicorn/nginx setup, not using any development settings like ./manage.py runserver or debug=true). The only difference I am aware of is that the staging server is served through http instead of https. Can anyone help fix the permissions error and to get logging running on production? Thanks in advance! Error -- Logs begin at Thu 2022-03-17 01:36:23 UTC, end at Sun 2022-03-20 22:41:48 UTC. -- Mar 20 22:40:00 mysite-prod gunicorn[419844]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import Mar 20 22:40:00 mysite-prod gunicorn[419844]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load Mar 20 22:40:00 mysite-prod gunicorn[419844]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked Mar 20 22:40:00 mysite-prod gunicorn[419844]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked Mar 20 22:40:00 mysite-prod gunicorn[419844]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module Mar 20 22:40:00 mysite-prod gunicorn[419844]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed Mar 20 22:40:00 mysite-prod gunicorn[419844]: File "/home/MySite/VicMySite/wsgi.py", line 15, in <module> Mar 20 22:40:00 mysite-prod gunicorn[419844]: … -
How to get time and memory usage of each Django request?
I am new in Django and I am trying to get time and memory usage of request in it. I created middleware what doesn't work. import os import psutil import sys import time class MiddlewareStats: def __init__(self, request): self.get_response = request def __call__(self, request): self.mem = psutil.Process(os.getpid()).memory_info() self.start_time = time.time_ns() response = self.get_response(request) total = time.time_ns() - self.start_time mem = psutil.Process(os.getpid()).memory_info() diff = mem.rss - self.mem.rss response["X-total-time"] = int(total) response["X-total-memory"] = int(diff) return response It returns strange numbers. High probably because I didn't understand how it works. Thank you for your help. Also I read this question, but it doesn't work already. -
Displaying variation.title (size option) in admin panel that were chosen by the user in HTML Template
In my project, there is a product.html page where the user can choose variations of the item and choose it. I don't know how to send the variant chosen by the user from a template (product.html) to admin panel. models.py Here is the models for OrderItem is where I want to send the value of a chosen size. Also, there is a Variation class for creating variants of the product. 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) size = models.ForeignKey(Variation, on_delete=models.CASCADE, null=True, default=Variation.title) @property def get_total(self): total = self.product.price * self.quantity return total def __str__(self): return self.product.name class Variation(models.Model): title = models.CharField(max_length=50) category = models.CharField(max_length=120, choices=VAR_CATEGORIES, default='size') price = models.DecimalField(null=True, blank=True, decimal_places=2, max_digits=100) product = models.ForeignKey(Product, on_delete=models.CASCADE) objects = VariationManager def __str__(self): return self.title product.html Here is the page for product detail for a chosen category. My drop down with sizes is here. {% extends "store/main.html" %} {% block content %} {% load static %} <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>undefined</title> <meta name="generator" content="Google Web Designer 14.0.4.1108"> <style type="text/css" id="gwd-text-style"> p { margin: 0px; } h1 { margin: 0px; } h2 { margin: 0px; } h3 … -
understanding mixins in django and their connection to HTTP methods
I'm watching a tutorial about django and I don't really get mixins. for example, is the RetrieveModelMixin corresponds to the GET method? it sounds like it should, since what the GET method is doing is retrieving data from the DB. but, there is also a ListModelMixin. is its function is to GET all object of a certain type? to be more specific, in the tutorial there is a general view that is defined as a combination of three mixins: class CustomerViewSet(CreateModelMixin, RetriveModelMixin, UpdateModelMixin, GenericViewSet): but, we he looks at the API page of the rest_framework module, this is written: Allow: POST, OPTIONS how can it not allow a PUT and PATCH methods if the Update mixins is included? how can it not allow a GET method if the Retrive mixins is included? -
Getting URL parameters in request.GET (Django)
How can i get all of those url parameters (1, 12-18, 5,Happy birthday)? in Django https://domain/method/?1='12-18'&5='Happy birthday' I have tried parameter = request.GET.get("1", "") but I only get 12-18. -
how to modify css file of django project deployed on heroku
I have deployed a django website on heroku. but after that I needed to modify the style.css. after modifications I commited and pushed the file to git. But there is no change in live website. How can I reflect the changes on live website. -
Dynamic textbox size using Django, HTML, CSS, Jquery
I am trying to configure Django form field with dynamic textbox expansion on overflow. For this I am using jquery <script> autosize($('#title')); </script> But the issue I am facing is that I have hardcoded a row size attr in my django form so on overflow it creates a scrollable textfield. However, when I remove this attr, the formfield takes up a much larger height than intended. How can I by default enable it to one row, but to auto expand on overflow? Thanks. relevant css <style> #title { font-size: 50px !important; color: rgb(120,120,120) !important; width: 100% !important; } </style> -
Authorization by phone number. The first request to enter a phone number
please help, maybe someone knows how to do this: Authorization by phone number. The first request to enter a phone number. Simulate sending a 4-digit authorization code (1-2 sec delay on the server). The second request to enter the code from django.contrib.auth.models import AbstractUser, BaseUserManager from django.db import models from django.utils.translation import ugettext_lazy as _ class CustomUserManager(BaseUserManager): """Define a model manager for User model with no username field.""" def _create_user(self, phone, password=None, **extra_fields): """Create and save a User with the given phone and password.""" if not phone: raise ValueError('The given phone must be set') user = self.model(phone=phone, **extra_fields) user.set_password(password) user.save(using=self._db) return user def create_user(self, phone, password=None, **extra_fields): extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(phone, password, **extra_fields) def create_superuser(self, phone, password=None, **extra_fields): """Create and save a SuperUser with the given phone and password.""" extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) if extra_fields.get('is_staff') is not True: raise ValueError('Superuser must have is_staff=True.') if extra_fields.get('is_superuser') is not True: raise ValueError('Superuser must have is_superuser=True.') return self._create_user(phone, password, **extra_fields) class CustomUser(AbstractUser): username = None phone = models.IntegerField(unique=True, verbose_name='Phone Number', blank=False) USERNAME_FIELD = 'phone' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return str(self.phone) -
How do I attach the user's order to the product issued Django
Ok, so I have this application where the users make an order for a Category through the app. Every category contains products. And what I want to do is when a product is issued to the user the order status for the order made by the user should change from 1(approved) to 4(issued) and the product name should be added in the order table to confirm the product that was issued to that request. How do I do that in Django? Below are my models class Category(models.Model): name = models.CharField(max_length=50, blank=True, null=True) timestamp = models.DateTimeField(auto_now_add=False, auto_now=True, null=True) class Product(models.Model): pro_name = models.CharField(max_length=100, blank=True, null=True) category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True) issue_to = models.ForeignKey('Order',default='', on_delete=models.CASCADE,blank=True, null=True) serial_num = models.CharField(max_length=100, blank=True, null=True) model_num = models.CharField(max_length=100, blank=True, null=True) storage_size = models.CharField(max_length=50, blank=True, null=True) memory_size = models.CharField(max_length=50, blank=True, null=True) supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE, blank=True, null=True) receive_quantity = models.IntegerField(default='0', blank=True, null=True) issue_quantity = models.IntegerField(default='0', blank=True, null=True) issue_by = models.CharField(max_length=50, blank=True, null=True) last_updated = models.DateTimeField(auto_now_add=False, auto_now=False, null=True) timestamp = models.DateTimeField(auto_now_add=False, auto_now=True, null=True) class Order(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE, null=True) pro_name = models.ForeignKey(Product, on_delete=models.CASCADE, null=True,related_name='product') staff = models.ForeignKey(User, on_delete=models.CASCADE, null=True) order_quantity = models.PositiveIntegerField(null=True) department = models.CharField(max_length=50, choices=DEPARTMENT, null=True) order_status = models.IntegerField(default=0) approve_quantity = models.IntegerField(default='1', blank=True, null=True) transaction_id … -
Django subqueries too slow
I'm working on a project in which users can have one profile, each profile can have many accounts, and an account can have many payments. The important parts of the models are the following: class Profile(models.Model): username = models.CharField(max_length=250) account = models.ForeignKey(Account) class Account(models.Model): payment = models.ForeignKey(Payment) class Payment(models.Model): amount = models.DecimalField(max_digits=8, decimal_places=2) account_id = models.CharField() # An unique id for the account the payment belongs I have to create an annotation in the Profile model with the Sum of the amounts of all payments from that user to manipulate this data with pandas afterwards. I managed to create a QuerySet using nested subqueries to get the job done, but this operation is extremely slow (slower than iterating through all of the profiles to calculate this value). Here is how I did it: payment_groups = Payment.objects.filter(account_id=OuterRef("pk")).order_by().values("account_id") payments_total = Subquery(payment_groups.annotate(total=Sum("amount")).values("total"), output_field=models.DecimalField()) account_groups = Account.objects.filter(profile=OuterRef("pk")).order_by().values("profile") accounts_total = Subquery(account_groups.annotate(total=Sum(paymments_total)).values("total"), output_field=models.DecimalField()) profiles = Profile.objects.all().annotate(account_total=acount_total) What in this code is making the subqueries so slow? I have done similar subqueries before to get the sum of fields in a child model. I know that doing this in a grandchild is more complex and requires more time but it shouldn't be that slow. Is there a … -
Compare and change DateTime object in SQL
I have model in my django project, which consists field like like given below uploadedTime = models.DateTimeField(auto_now_add=True, blank=True) And this saves dateTime object something like this.. 2022-03-21 17:53:15.156665 I want to make such a function which will take this dateTime object from database and will compare this with current dateTime() object, And if there's more than 2 hours gap between them then it will return true else false. Inshort I want all the entries from database which were inserted to database two hours ago. I tried many ways and reading docs but can't find a correct way, Can anyone guide me how to do this? Thank You :) -
How to give access to a object of a model to different users in django
I am doing an online classroom project in Django where I created a model named create_course which is accessible by teachers. Now I am trying to add students in a particular class by inviting students or by "clasroom_id". I added the models and views of the course object below. models.py class course(models.Model): course_name = models.CharField(max_length=200) course_id = models.CharField(max_length=10) course_sec = models.IntegerField() classroom_id = models.CharField(max_length=50,unique=True) created_by = models.ForeignKey(User,on_delete=models.CASCADE) def __str__(self): return self.course_name def is_valid(self): pass views.py def teacher_view(request, *args, **kwargs): form = add_course(request.POST or None) context = {} if form.is_valid(): course = form.save(commit=False) course.created_by = request.user course.save() return HttpResponse("Class Created Sucessfully") context['add_courses'] = form return render(request, 'teacherview.html', context) def view_courses(request, *args, **kwargs): students = course.objects.filter(created_by=request.user) dict = {'course':students} return render(request, 'teacherhome.html',dict) -
create text for django class without importing all django code
I am writing a desktop application around objects that will be downloaded from a django website. On the desktop application I will load a json file coming from the website. Therefore I need a set of classes in my desktop application , lets call them WClassA, wClassB, .... and a set of classes in my django application DClassA, DClassB. I would like to avoid to write the classes twice. What is the solution to avoid code duplication? I cannot import Django classes in my application because this would require to import all django. I thought about defining having a "fake django" Model file in my desktop application. But it loos kind of dirty. -
Django I'm trying do perform a simple task, display on the page whatever was input in a textfield
All I want is the user to type in something in a single textfield and have the input displayed on the same page by the form. Please help!!!! I tried so many solutions nothing seems to work and its such a simple task please see my code: views.py def math_drills(request): num1 = random.randint(0,100) num2 = random.randint(0,100) total = num2 + num1 if request.method == 'POST': form = Addition(request.POST) u_i = request.POST['uans'] return redirect('math_drills_url') return render(request,'math_drills.html',{ 'num1':num1, 'num2':num2, 'total':total, }) html <div class="col-lg-12"> <script type="text/javascript"> </script> <label class="" id="num1" name="">{{num1}}</label> + <label class="" id="num2" name="">{{num2}}</label> = <form action="" method="post"> {% csrf_token %} <input id="your_name" type="text" name="uans" value="" id="" style="width:2%;"> <input type="submit" value="add"> </form> </div> -
How to add list_display fields from a reverse relationship in django admin
I'm pretty new to django and the admin module. I'm looking for a way to add on a admin class some fields that i query through a reverse relationship. I can currently retrieve the interesting fields and put them in one column thanks to a specific function using list_diplay, but i cannot manage to create a list_display field BY returned query object: as example, now I get as column: |Inventory_id| Mousqueton1 | | 22 | foo1,foo2 | and i would like to have this kind of output, to easily create filters: |Inventory_id| Mousqueton1 | Mousqueton2 | | 22 | foo1 | foo2 | Here's my current models.py class Kit(models.Model): inventory_id = models.CharField(max_length=20,unique=True) description = models.TextField(null=True) creation_date = models.DateField(auto_now_add=True) last_update = models.DateTimeField(auto_now=True) class Mousquetons(models.Model): inventory_id = models.CharField(max_length=20,unique=True) serial = models.IntegerField(unique=False) description = models.TextField(null=True) creation_date = models.DateField(auto_now_add=True) last_update = models.DateTimeField(auto_now=True) kit = models.ForeignKey(Kit,on_delete=models.PROTECT,null=True) and admin.py @admin.register(Kit) class KitAdmin(admin.ModelAdmin): list_display= ['inventory_id','m'] def get_queryset(self, obj): qs = super(KitAdmin, self).get_queryset(obj) return qs.prefetch_related('mousquetons_set') def m(self, obj): return list(obj.mousquetons_set.all()) Maybe my data modeling is not the right way to perform this kind of operation, Any advice would be great. Thanks ! -
django model form initial instance does not add images
hi guys I am trying to set up a simple model form that has some instance as initial values, I have an image field and it causes problems because it is required, and the initial value is empty, I know I could get around it by setting it to not required and validating it in a custom validation but I was wondering if there was a simpler way or maybe a library to this this is my form class adminPackageForm(forms.ModelForm): class Meta: model = package fields = ("__all__") and I am rendering it using the crispy tailwind theme -
Django - sorting results ("choice") by number of votes
I don't know how to display on the page the result of each "choice" in descending order depending on the number of "votes" received. Please help me with a solution. Below is my setup. Thank you! models.py class Question(models.Model): question_text = models.CharField(max_length=200, verbose_name='Intrebare') pub_date = models.DateTimeField('publicat la:') def __str__(self): return self.question_text class Meta: verbose_name = 'Intrebari sondaj' verbose_name_plural = 'Intrebari sondaj' class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200, verbose_name='') votes = models.IntegerField(default=0) def __str__(self): return self.choice_text class Meta: verbose_name = 'Variante raspuns' verbose_name_plural = 'Variante raspuns' views.py # preluare si afisare intrebari din sondaj def index(request): latest_question_list = Question.objects.order_by('-pub_date')[:5] context = {'latest_question_list': latest_question_list} return render(request, 'sondaj/index.html', context) # afisare optiuni aferente fiecarei intrebari din sondaj si intrebare in sine def detail(request, question_id): try: question = Question.objects.get(pk=question_id) except Question.DoesNotExist: raise Http404("Nu exista sondaje publicate") return render(request, 'sondaj/detail.html', {'question' : question}) # preluare si afisare rezultate la nivelul fiecarei intrebari sondaj @login_required(login_url='/') def results(request, question_id): question = get_object_or_404(Question, pk=question_id) comments = question.comments return render(request, 'sondaj/results.html', {'question': question, 'comments' : comments}) # listare optiuni de ales pentru fiecare intrebare din sondaj def vote(request, question_id): #print (request.POST['choice']) question = get_object_or_404(Question, pk=question_id) try: selected_choice = question.choice_set.get(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): # reafisare intrebare sondaj … -
How to access the actor of a django notification in a usable format?
I am using django-notifications (here is the code) to create notifications for my web app. I have the issue of whenever I try to access the the actor object e.g. via Notification.object.get(id=1).actor I get the following exception: ValueError: Field 'id' expected a number but got '<property object at 0x7fc171cc5400>'. which then causes then exception: ValueError: invalid literal for int() with base 10: '<property object at 0x7fc171cc5400>' Here is the code for my signal: @receiver(post_save, sender=ClubJoinRequest) def notify_owner_of_request(sender, instance, created, **kwargs): """ Notification for when a user has requested to join a club, the club owner will receive a notification. """ if created: notify.send( sender=sender, actor = instance.user, verb = "requested to join ", recipient = instance.club.owner, action_object = instance, target = instance.club, ) No matter what kind of object or value I make the actor it always has the same error. To note, I can access action_object, target, verb, and recipient perfectly fine, and the notification does work (there is one made and correctly). The Notification model from notification-hq has the following attributes: actor_content_type = models.ForeignKey(ContentType, related_name='notify_actor', on_delete=models.CASCADE) actor_object_id = models.CharField(max_length=255) actor = GenericForeignKey('actor_content_type', 'actor_object_id') accessing actor_content_type gives me this: <ContentType: clubs | club join request> even though it should … -
I'm trying populate script where I kept os.environ.setdefault('DJANGO_SETTING_MODULS','todolist.settings') before django.setup() but its not working
import os os.environ.setdefault('DJANGO_SETTING_MODULS','todolist.settings') import django django.setup() import random from todo.models import Todo from faker import Faker fakegan = Faker() todos = ['goals','workout','2lit water'] def add_todo(): q = Todo.objects.get_or_create(title=random.choice(todos))[0] q.save() return t def populate(N=5): for entry in range(N): top = add_todo() fake_title = fakegan.title() if __name__ == '__main__': print('populating fake_data') populate(20) print('populating complated!') Error: django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.