Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django: is it safe to remove `blank=True` from web-service only app?
I'm starting a project using an existing db. The models generated from inspectdb have (...null=True, blank=True) in various fields. The documentation mentions that the blank argument is related to django forms. I'm making a web service project, using django rest framework and the django ORM. Absolutely no view component (autogenerated forms, html templates, etc) of the MVC. Does that mean it's safe to remove blank=True from my models? -
Django Not Use Primary Key?
django not use primary key. My table explain -mid(varchar(4)) -phone(varchar(11)) not need primary key. django primary key remove. -
Add forms in formset with Django and JS
I would like to be able to add dynamically django forms in my formset with Add button. I tried to write different things but I don't overcome to get the expected result up to now. I have a formset defined in my forms.py file : AnimalFormSet = inlineformset_factory(Elevage, Animal, form=AnimalForm, extra=1) Then, I created in my views.py file this function : class ElevageCreateView(CreateView): model = Elevage template_name = 'elevage_form.html' def get_context_data(self, **kwargs): context = super(ElevageCreateView, self).get_context_data(**kwargs) context['AnimalFormSet'] = AnimalFormSet(self.request.POST or None, self.request.FILES or None) return context def form_valid(self, form): context = self.get_context_data() animal = context['AnimalFormSet'] if animal.is_valid(): self.object = form.save() animal.instance = self.object animal.save() return super(ElevageCreateView, self).form_valid(form) def get_success_url(self): return reverse('animal-list') Finally, I'm trying to write my template file : <fieldset> <legend class="title"><span class="name">{% trans 'Animal form' %}</span></legend> {{ AnimalFormSet.management_form }} {% for form in AnimalFormSet.forms %} <table class='no_error'> {{ form.as_table }} </table> {% endfor %} <input type="button" class="btn btn-default" value="Add More" id="add_more"> <script> $('#add_more').click(function () { cloneMore('div.table:last', 'service'); }); </script> </fieldset> And I have javascript function : <script> function cloneMore(selector, type) { var newElement = $(selector).clone(true); var total = $('#id_' + type + '-TOTAL_FORMS').val(); newElement.find(':input').each(function() { var name = $(this).attr('name').replace('-' + (total-1) + '-','-' + total + '-'); var … -
Python tuples manipulation
I have a tuple in Python like this - a = ((-,-,x), (-,-,x), (-,-,y), (-,-,z), (-,-,z), (-,-,z)) Now, I want to group the tuples with the same third element. I have to convert this tuple,a into b = (((-,-,x), (-,-,x)), ((-,-,y)), ((-,-,z), (-,-,z), (-,-,z))) How do I write Python code for this? To convert a into b? Since tuples are immutable I'm not able to write the code successfully. -
How to use sql statement in django?
I want to get the latest date from my database. Here is my sql statement. select "RegDate" from "Dev" where "RegDate" = ( select max("RegDate") from "Dev") It works in my database. But how can I use it in django? I tried these codes but it return error. These code are in views.py. Version 1: lastest_date = Dev.objects.filter(reg_date=max(reg_date)) Error: 'NoneType' object is not iterable Version 2: last_activation_date = Dev.objects.filter(regdate='reg_date').order_by('-regdate')[0] Error: "'reg_date' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format." I've defined reg_date at beginning of the class. What should I do for this? -
What determines what fields can be updated in DjangoRestFramework
I currently have a serializer with the following fields class Meta: model = Asset fields = ('id', 'uuid', 'asset_category', 'asset_sub_category', 'make_label', 'asset_code', 'serial_number', 'model_number', 'checkin_status', 'created_at', 'last_modified', 'current_status', 'asset_type', 'allocation_history', 'specs', 'purchase_date', 'notes', 'assigned_to', 'asset_location' ) However, on the browsable Api, only 4 fields are showing on the UPDATE/PUT form as shown in the diagram below What could be the reason some of the other fields are not appearing here. What determines which fields are updatable?? -
django override delete cascade for one time
Is there an option for to make sure that a model instance does not have any related objects? i.e, if the Person object has any related objects, I want this line person.delete() to raise an error. And I don't want to modify on_delete=models.CASCADE for every foreign key. I need this protection only here, for any other case in my application (like django admin site) I do prefer the cascading behavior. -
django-haystack returning unexpected results
I am trying to integrate django-haystack on a blog. Here is my Post model: class Post(models.Model): slug = models.CharField(max_length=2000) title = models.CharField(max_length=2000) content = models.TextField(blank=True) created_on = models.DateTimeField(auto_now_add=True) updated_on = models.DateTimeField(auto_now=True) user = models.ForeignKey(UserProfile, on_delete=models.CASCADE) def __str__(self): return self.title Here is the how code in search_indexes.py file: class PostIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField(document=True, use_template=True) title = indexes.CharField(model_attr='title') content = indexes.CharField(model_attr='content') def get_model(self): return Post def index_queryset(self, using=None): """Used when the entire index for model is updated.""" return self.get_model().objects.filter(created_on__lte=datetime.datetime.now()) As you can see, I am using EdgeNgramField type to search for partial terms. Now if I search for the term elastic, as expected, haystack returns post containing elastic somewhere either title or content field. However, haystack also returns some additional posts which do not have the term elastic neither in title or nor in content. How can I fix this? I have tested this code on: django-haystack (2.8.1), elasticsearch-2.4.2, and django-1.11 PS: This is my first encounter with elastic search. -
Django ViewFlow: Navigate Step based on Validation
I am using the HelloWorld example located at the ViewFlow cookbook. The whole source code is same as the helloworld project with the only change being: flows.py check_approve = ( flow.If(lambda activation: activation.process.approved) .Then(this.send) .Else(this.start) # Edited (was this.end) ) So basically I intend that if user keeps the Approved checkbox as un-selected and proceeds then it will push the task back to the start step. I get this error when I run it: NotImplementedError at /workflow/helloworld/helloworld/3/approve/11/ No exception message supplied Internal Server Error: /workflow/helloworld/helloworld/3/approve/11/ Traceback (most recent call last): File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, *args, **kwargs) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 67, in _wrapper return bound_func(*args, **kwargs) File "/usr/lib/python3.6/contextlib.py", line 52, in inner return func(*args, **kwds) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/viewflow/decorators.py", line 213, in _wrapper return view(request, **kwargs) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 63, in bound_func return func.__get__(self, type(self))(*args2, **kwargs2) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/viewflow/flow/views/task.py", line 70, in dispatch return super(BaseFlowMixin, self).dispatch(request, **kwargs) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch return handler(request, *args, **kwargs) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/views/generic/edit.py", line 240, in post return super(BaseUpdateView, self).post(request, *args, **kwargs) File "/home/admin-12/PycharmProjects/viewflow1/venv/lib/python3.6/site-packages/django/views/generic/edit.py", … -
Axios headers work for Django GET request, but not PUT request
I can sucessfully make a GET request on my /rest-auth/user/ api with axios and this header {headers: { 'authorization': `Token ${token}`}} But when I try to make a PUT request, I get 401 unauthorized. This is the full code of my request: export const addCountry = (countries) => { const token = localStorage.getItem('token'); return dispatch => { dispatch(addCountryPending()); axios.put( 'http://localhost:8000/api/v1/rest-auth/user/', {headers: { 'authorization': `Token ${token}`}}, {countries: countries} ) .then(response => { const user = response.data; dispatch(addCountryFulfilled(user)); }) .catch(err => { dispatch(addCountryRejected(err)); }) } } and my Django permissions are set as REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.TokenAuthentication', ], Does anyone know what I'm doing wrong? Thanks! -
django.db.utils.InterfaceError: (0, '')
I've recently implemented django in a tool I'm developing. While doing some tests I have been getting an django.db.utils.InterfaceError: (0, '') error. I have read that it might be a global cursor issue, however I am only doing queries through django, letting it handle the cursors. Basically I have information about compounds which, I save to mySQL during several moments of the tool execution. This particular piece of code will execute several times (which seems to work fine so far) and will then execute one final time in the end of the execution ( a global save). It is in this global save that I am getting the aforementioned error. This global save just iterates over all collected compounds and saves them. Any ideas on what I can do to solve this error? def save_to_SQL_db(self): #####COMPOUND##### if not self.sql_key: cpd_django=Compound_db(cpd_level=self.get_cpd_level(),\ chemical_formula=self.get_Chemical_formula(),\ smiles=self.get_SMILES()) else: cpd_django=Compound_db.objects.get(pk=self.sql_key) cpd_django.cpd_level=self.get_cpd_level() cpd_django.chemical_formula=self.get_Chemical_formula() cpd_django.smiles=self.get_SMILES() cpd_django.save() Error: Traceback (most recent call last): File "user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\backends\mysql\base.py", line 71, in execute return self.cursor.execute(query, args) File "user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\cursors.py", line 170, in execute result = self._query(query) File "user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\cursors.py", line 328, in _query conn.query(q) File "user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\connections.py", line 515, in query self._execute_command(COMMAND.COM_QUERY, sql) File "user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\connections.py", line 745, … -
Django - ManyToMany through synthetic relation fields
I have such models in my application: class User(AbstractUser): pass class MyObject(models.Model): name = models.CharField(max_length=200, unique=False, db_index=True) related_users = models.ManyToManyField( User, through='RelatedUsers', related_name='related_users' ) class RelatedUsers(models.Model): my_object = models.ForeignKey( MyObject, related_name='my_object_related_users' ) user = models.ForeignKey(User) type = models.CharField( max_length=100, choices=RelatedUsersTypes.choices() ) class Meta: unique_together = ('user', 'my_object', 'type') class FunctionalityRelatedUsersTypes(BaseChoiceEnum): TYPE_1 = 'TYPE 1' TYPE_2 = 'TYPE 2' TYPE_3 = 'TYPE 3' TYPE_4 = 'TYPE 4' TYPE_5 = 'TYPE 5' I'm wondering if there is an option to create some kind of synthetic relations on MyObject. I would like to be able to get users by type using one field, example: related_users_type_1. I'd like to use it in DRF serializer as well (so I can pass just List of ids, and relation will create a Proxy object with the corresponding type). Pseudocode: related_users_type_1 = models.RelationField(RelatedUsers, filter={'type': 'TYPE_1'}) Sample payload I want to send: { "related_users_type_1": [1, 2, 3], "related_users_type_2": [3] } Expected result: 3 RelatedUsers with TYPE_1 1 RelatedUser with TYPE_2 -
What is the django query to find the records where the searching date is between two columns are not?
"select * from resource_management where ('2015-11-08' between employee_effective_start_date and employee_effective_end_date )" I want the above sql query to be executed using Django orm(QUERYS) can anyone please help me how it should be framed in Django. Is it using annotation! Thanks for dropping by. -
Django Rest Framework - POST slowness when body size greater than 1024 characters
I'm using DRF. I found that receiving a POST with more than 1024 characters causes a ~1 second penalty, while anything less than that is effectively free. I've simplified this into this trivial example: # views.py import time from rest_framework.decorators import api_view from django.http import HttpResponse @api_view(['POST']) def test_endpoint(request): t = time.time() data = request.body total_time = time.time() - t print('got post data:', round(total_time, 3)) return HttpResponse('body size:{} time:{}'.format(len(data), round(total_time, 3))) # url.py urlpatterns = [ url(r'^test_endpoint', test_endpoint), ] You can see that all I'm doing is reading the request.body and measuring the time it takes to do so. Then I respond with that time, and the len of the request.body (to prove I accessed it). Then I execute these curls: $ time curl -X POST http://127.0.0.1:8000/test_endpoint -d 0123456782345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567901234567890123456789012345678901234567 body size:1024 time:0.0 real 0m0.045s user 0m0.006s sys 0m0.009s $ time curl -X POST http://127.0.0.1:8000/test_endpoint -d 01234567823456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345679012345678901234567890123456789012345678 body size:1025 time:0.999 real 0m1.020s user 0m0.006s sys 0m0.006s You can see the second one has one extra character, and that causes a ~1 second penalty to ready request.body. Why is that? How can I prevent this? -
How to test in Django if the database retrieval logic sits in the view
I am using Django and two databases namely NDB and SQlite for different purposes. I have gone through testing topics in django, they tell to create database in the test and call the view/function for that object. My scenario is different. I have database logic sitting in my function/view to test. So I cannot create a test database and test test function. My view class NewsFeedViewSet(viewsets.ViewSet): lookup_field = 'username' def retrieve(self, request , username=None): user_and_followers_list=[] posts_list = [] post_dict = {} ancestor_key = ndb.Key(Follow, username) user_followers = Follow.query_followers(ancestor_key) for followers in user_followers: user_and_followers_list.append(str(followers.following)) user_and_followers_list.append(str(username)) posts = Post.query(Post.owner.IN(user_and_followers_list), Post.date < time_stamp).fetch(100) for p in posts: post_dict = p.to_dict() posts_list.append(post_dict) users = User.objects.filter(username__in=user_and_followers_list) for post in posts_list: user = users.get(username=post['owner']) serializer = UserSerializer(user) post['user'] = serializer.data posts_list = sorted(posts_list, key=lambda k: k['date'], reverse=True) global time_stamp if len(posts_list) > 0: time_stamp = posts_list[len(posts_list)-1]['date'] return Response(posts_list) Is there anyway to hit my production database and have my server running while I test? Or any different and efficient approach I could go with? -
Bulk Update in Djangorestframework
I want to perform Bulk update using django restframework, https://github.com/miki725/django-rest-framework-bulk , i tried to use this package without success. Anyone knows how to do bulkupdate -
Unable to connect from django to mysql database
I have created the database on XAMPP mysql which is up and running. The database is created, I am now trying to connect from django with the following connection parameters, DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': "djangoproject", 'USER': 'root', 'PASSWORD': '******', 'HOST': 'localhost', 'PORT': '' } } I am getting the following error when executing python3 manage.py runserver and python3 manage.py migrate django.db.utils.OperationalError: (1049, "Unknown database 'djangoproject'") I have read a solution to create the database from mysql shell using the create database statement. My question is why i am not able to connect to the database already created on XAMPP mysql. -
Model-less views with dynamic rest
Here is a very good description on how to implement model-less views with django-rest-framework. How can we do the same with the dynamic-rest extension the the django-rest-framework? -
Save and retrieve processed list in Django
I have one process list (like [["a","b","c"],["c","d","e"]]) in django and want to save such data in sql. I have built a class in model for such data as followed. class Results(models.Model): batch_id = models.AutoField(primary_key=True) batch_cola = models.CharField(max_length=1000) batch_colb = models.CharField(max_length=1000) batch_colc = models.CharField(max_length=1000) owner = models.ForeignKey(User, on_delete=models.CASCADE) I just want to know how could I edit the coding in the view.py function for save such list and retrieve such list? I need the retrieved data can still be like [["a","b","c"],["c","d","e"]]. Here's what I do but error appears as "table XX_result has no column named owner_id”. list for t in list: Results.objects.create(batch_cola=t[0], batch_colb=t[1], batch_colc=t[2]) data = Results.objects.filter(owner=request.user) return render(request, "projects/results.html", {"datas": data}) -
How to handle authorization in Django and Vue js web app
I am currently in the process of creating a backend for a front end app I built. And while trying to understand how the whole system is going to work I stumbled with this kind of question. So I got really curious is Token-Based Auth good enough? Let`s say that it is good enough and now I have my tokens that I check for every API request. But then how do I handle it front end wise. For example, I would be creating dashboard where some tabs would be hidden for non-admins. Would I just manually hide it depending on the outcome of token? Or is there any other better way? Couldn't really find this kind of information online. Thats why I`m asking. -
How to call a Django view function Asynchronously (AJAX) using Vue
I have a form with a button other then submit button. I would like Vue to call a Django view asynchronously when that button is clicked and return a JSON message saying function was called successfully. -
Python Django 2 Email Verification on User SignUp
I'm working on a project using Python(3.6) and Django(2.0) in which I need to verify the user's email on registration. Here's what I have tried: App to users named as users forms.py class SignUpForm(UserCreationForm): first_name = forms.CharField(max_length=30, required=False, help_text='Optional.') last_name = forms.CharField(max_length=30, required=False, help_text='Optional.') email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.') class Meta: model = User fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2') def save(self, commit=True): user = super(SignUpForm, self).save(commit=False) user.email = self.cleaned_data['email'] user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] user.password = self.cleaned_data['password1'] if commit: user.save() return user urls.py: urlpatterns = [ path('signup/', views.SignUpView.as_view(), name='signup'), path('login/', views.LoginView.as_view(), name='login'), path('logout/', views.LogoutView.as_view(), name='logout'), url(r'^activate/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', views.activate, name='activate'), views.py: class SignUpView(generic.CreateView): form_class = forms.SignUpForm template_name = 'users/signup.html' success_url = reverse_lazy('users:login') form_valid_message = 'User has been created successfully!' form_invalid_message = 'Something wrong' def post(self, request, *args, **kwargs): if request.method == 'POST': print('Get post signup') form = forms.SignUpForm(request.POST) print(request.POST) if form.is_valid(): print('Form is valid') fd = form.cleaned_data username = fd['username'] email = fd['email'] password1 = fd['password1'] password2 = fd['password2'] password = None if password1 == password2: password = password1 if not (User.objects.filter(username=username).exists() or User.objects.filter(email=email).exists()): userObj = User.objects.create_user(username, email, password) userObj.first_name = fd['first_name'] userObj.last_name = fd['last_name'] userObj.is_active = False userObj.save() print(userObj) current_site = get_current_site(request) mail_subject … -
Current directory in Python module search path not working for django-admin
I was studying a document on Django settings. It reminds us that the settings module should be on the Python import search path. So I added the following two lines to .bashrc as suggested in here: -dell:~/Documents/DjangoTutorial$ tail -2 ~/.bashrc export PYTHONPATH=$HOME/Documents/DjangoTutorial/mysite export DJANGO_SETTINGS_MODULE=mysite.settings -dell:~/Documents/DjangoTutorial$ . ~/.bashrc and "django-admin runserver" is working from anywhere, with sys.path in Python3.7 showing: >>> sys.path ['', '/home/Documents/DjangoTutorial/mysite', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages'] Then I read article1 and article2 which imply that "sys.path" consists of : current dir.(denoted as ''), PYTHONPATH, standard and installed libraries. So I invoked django-admin strictly from the PYTHONPATH directory but commented out "#export PYTHONPATH" in ./bashrc and got an error as shown below: -dell:~/Documents/DjangoTutorial/mysite$ django-admin runserver Traceback (most recent call last): ... **ModuleNotFoundError**: No module named 'mysite' I then checked sys.path and '' was there: -dell:~/Documents/DjangoTutorial/mysite$ python3 >>> sys.path ['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages'] My question is that if '' is equal to PYTHONPATH in this case and why cannot it find the settings module? -
Combining JavaScript and Django
I am building a web app and I have some python function for machine learning and I would like to use them via a click button in javascript. How can I do it, please? Thanks -
Django log (how set path, what data type, where to view the log)
I'm sorry to ask about I'm new to anything related to coding. I'm trying to set up log to be able to test my code; Django pass variable into template and I was following the example in https://docs.djangoproject.com/en/2.1/topics/logging/ Here the code they use LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'file': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'filename': '/path/to/django/debug.log', }, }, 'loggers': { 'django': { 'handlers': ['file'], 'level': 'DEBUG', 'propagate': True, }, }, } But i run into this problem; C:\Users\Sk\Desktop\FrounterWeb>py manage.py runserver Unhandled exception in thread started by <function check_errors. <locals>.wrapper at 0x0000020C5F857268> Traceback (most recent call last): File "C:\Users\Sk\AppData\Local\Programs\Python\Python37\lib\logging\config.py", line 692, in configure_handler formatter = self.config['formatters'][formatter] File "C:\Users\Sk\AppData\Local\Programs\Python\Python37\lib\logging\config.py", line 315, in __getitem__ value = dict.__getitem__(self, key) KeyError: 'verbose' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\Sk\AppData\Local\Programs\Python\Python37\lib\logging\config.py", line 555, in configure handler = self.configure_handler(handlers[name]) File "C:\Users\Sk\AppData\Local\Programs\Python\Python37\lib\logging\config.py", line 695, in configure_handler '%r' % formatter) from e ValueError: Unable to set formatter 'verbose' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\Sk\AppData\Local\Programs\Python\Python37\lib\site- packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\Sk\AppData\Local\Programs\Python\Python37\lib\site- packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Users\Sk\AppData\Local\Programs\Python\Python37\lib\site- packages\django\utils\autoreload.py", line …