Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
No module names 'notifications.signals'; 'notifications' is not a package
Hello I have a problem with a Django project. When I ran in Pycharm the celery I got this error : No module named 'notifications.signals'; 'notifications' is not a package Althought when I type in Python Console this : from notifications.signals import notify Could you help me please ? Thank you very much -
Django Type Eroor at add
I want to create a function that returns the list of last points per vehicle that have sent navigation data in the last 48 hours. I create a view it works and it displays name correctly but when I want to add new Vehicle from Django Admin panel it shows an error. TypeError at /admin/navigation/navigationrecord/add/ str returned non-string (type int) How can I fixed it? And is there a more afformative and efficient way to list data over the past 48 hours? models.py class Vehicle(models.Model): id = models.IntegerField(primary_key=True) plate = models.CharField(max_length=30) def __str__(self): return str(self.plate) class NavigationRecord(models.Model): id = models.IntegerField(primary_key=True) vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE) datetime = models.DateField(default=timezone.now) latitude = models.FloatField() longitude = models.FloatField() def __str__(self): return self.vehicle views.py def get_48_hours(request): time_48 = datetime.now() - timedelta(hours=48) results = NavigationRecord.objects.filter(datetime__gte=time_48) context = { 'results': results, } return render(request, 'navigation.html', context) navigation.html <table class="table table-hover"> <thead> <tr> <th>ID</th> <th>Vehicle</th> </tr> </thead> <tbody> {% for result in results %} <tr> <td>{{result.id}}</td> <td>{{result.vehicle}}</td> <td>{{result.datetime}}</td> </tr> {% endfor %} </tbody> </table> admin.py models = [Vehicle, NavigationRecord] admin.site.register(models) traceback Environment: Request Method: GET Request URL: http://127.0.0.1:8000/admin/navigation/navigationrecord/add/ Django Version: 2.2.13 Python Version: 3.7.0 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'navigation'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', … -
how to redirect different login page to different type of users in django admin after login?
i created user - user 1 assigned group A user 2 assigned group B now i created login page and after login as user1 i want to redirect to page1.html and if logged in as user2 then redirect to page2.html for this i wrote def login(request): if request.method == 'POST': user = auth.authenticate(username=request.POST['username'], password=request.POST['password']) if user is not None: auth.login(request,user) if user.usergroup=='A': return redirect('pages/page1.html') else: return redirect('pages/page2.html') else: messages.error(request,'Invalid credentials') return redirect('login') # User is authenticate else: return render(request,'pages/login.html') with this i logged in as user1 ,got the error AttributeError at / 'User' object has no attribute 'usergroup' kindly help -
Django Model Tree
I need to create next logic, but i stack in modeling. i think: user1 give invite code to user2, user2 give invite code 3 and etc.. when user give invate for every next user we are increment invation counter for example to user2 and etc. task: The user can generate his own invitation code. Each user has his current points. The scoring scheme is as follows: The prize fund for the successful use of the invitation code is N points, where N is the current number of registered users of the owner of the code + 1. The prize fund is distributed according to the scheme: the owner of the code 1 point, the one who attracted the owner 1 point, and so on, until one of the conditions is reached: a) N == 0 b) the top of the tree is reached In case b and if N> 0, the user at the top gets the entire value of N User can watch other those who attracted him and the list of people he attracted. I created some models and know what do next :( class User(AbstractUser): invation_code = models.CharField(max_length=128, blank=True) points = models.PositiveIntegerField(default=0) class Invation(MPTTModel): invation_from = models.ForeignKey(User, … -
Do I need foreign key reference when using separate schemas for tenants?
I am doing research for database design for a SaaS application. I studied this article where 3 approaches are discussed. Separate database for each tenant, Shared database but separate schemas and Shared database and schema with foreign key reference to the tenant table. The first approach is out of the question for me. From the 2nd and 3rd, 2nd approach suits best my situation. I have Django on top of PostgreSQL. I, ll create a separate schema for each tenant. For serving every (web) request, I'll identify the current user's schema and set it using SET SCHEMA before querying the database. 3rd option is to add tenant id in every database table and query accordingly. My question is how secure is 2nd approach considering Django running as web application on top of the database? Are there any chances of data leakage considering there can exist cross schema foreign key references? Should I also add a foreign key in tables as an extra layer of security and query accordingly? -
Django static files css,fonts,img
I've received static files from a friend who've working on front-end stuff I'm trying to implement them in django project. I've learned I can approach django static files through {% static '' %} at html file But I have no idea to approach fonts and pictures at CSS file. fonts are designated in this format at CSS file @font-face { Src: url('../fonts/SansBold.otf');} and images are designated in this format at CSS file .hero-header { background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url('../images/img2.jpg');} So How can I approach the static file and use them at css file? -
How do I solve failed to find attribute `application` in `folder.myproject`
How do I solve this error, I keep on getting it for deployment to heroku The web server I use is gunicorn Failed to find attribute 'application' in 'src.website_viewer'. -
Add Django elements locally to ManyToMany fields without saving them in the database, comparable to the setattr function, only for M2M fields
I was looking to see if there was a way to add local items to a ManyToMany field without storing them in the database. I want to be able to do the same with a ManyToMany field as I would with a ForeignKeyField or other fields of a Django model. There is a function setattr (obj, field.name, <newValue>) for these fields. These changes are not saved in the database, but I can access them in templates, for example. I would be very happy if someone could give me a hint whether there is something similar for ManyToMany Fields. I've struggled with this problem for quite a while and haven't found anything about it. Thanks in advance :) -
Transform function to class based view (recall same site)
Very similar to these questions I want to transform my view. The difference is that I want to return to the same page and I have problems adjusting my urls.py (I think): So on the product_all.html I press a button and end up on the same page after the product was deleted: def delete_product(request, pk): Product.objects.filter(id=pk).delete() context = {'Product': Product.objects.all()} return render(request, 'gbkiosk/product_all.html', context) urls.py: path("product_delete/<int:pk>", views.delete_product, name='product-delete'), I wanted to recreate that using a TemplateView: class DeleteProduct(TemplateView): template_name = "gbkiosk/device_all.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) Product.objects.filter(id=kwargs["product_id"]).delete() context["products"] = Product.objects.all() return context but what would the corresponding urls.py entry be?: path("product_delete/<int:product_id>", views.DeleteProduct.as_view(), name="product-delete") This will not return me to product_all.html after clicking? -
Is it possible to change the definition of model field using a proxy model?
With a proxy model, it is possible to extend and overwrite the functionality of the base model's methods. But is it also possible to manipulate the base model's fields? from django.db import models class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) class MyPerson(Person): class Meta: proxy = True # Somehow extend first_name to have max_length of 50. # Add an integer field called `points` -
Object of type MxCreateSerializer is not JSON serializable
I am working on a django project and I have a django model Message: class Message(models.Model): content = models.TextField(_('Content')) sender = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='sent_dm', verbose_name=_("Sender"),on_delete=models.CASCADE) recipient = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='received_dm', verbose_name=_("Recipient"),on_delete=models.CASCADE) sent_at = models.DateTimeField(_("sent at"), null=True, blank=True) views.py class MessageCreateView(APIView): queryset = Message.objects.all() serializer_class = MxCreateSerializer def get(self, request, format=None): serializer = MxCreateSerializer() return Response({'serializer':serializer}) def post(self, request): sent_data = request.data #print(sent_data) data_ = [elem for elem in sent_data.values()] sender = data_[0] content = data_[1] recipient = data_[2] csrf = data_[3] sender = get_object_or_404(User,username=sender).username recipient = get_object_or_404(User,username=recipient).username new_resp = {'sender':sender,'content':content,'recipient':recipient, 'csrfmiddlewaretoken':csrf} qdict = QueryDict('', mutable=True) qdict.update(new_resp) #print(qdict) serializer = MxCreateSerializer(data=qdict) if not serializer.is_valid(): return Response({'message':'no'}) serializer.save() return Response({'message':'yes'}) serializers.py class MxCreateSerializer(serializers.ModelSerializer): class Meta: model = Message fields = ['sender','content','recipient'] def create(self, validated_data): message = Message.objects.create(**validated_data) print(message) return message I get this error: Traceback (most recent call last): ... File "/.../site-packages/django/template/response.py", line 105, in render self.content = self.rendered_content File "/.../site-packages/rest_framework/response.py", line 70, in rendered_content ret = renderer.render(self.data, accepted_media_type, context) File "/.../site-packages/rest_framework/renderers.py", line 724, in render context = self.get_context(data, accepted_media_type, renderer_context) File "/.../site-packages/rest_framework/renderers.py", line 680, in get_context 'content': self.get_content(renderer, data, accepted_media_type, renderer_context), File "/.../site-packages/rest_framework/renderers.py", line 413, in get_content content = renderer.render(data, accepted_media_type, renderer_context) File "/.../site-packages/rest_framework/renderers.py", line 103, in render allow_nan=not self.strict, separators=separators File "/.../site-packages/rest_framework/utils/json.py", … -
Looping Initial Data for Formset Django
I want to set initial data at formset for TimeField's field every 1 hour as much 24. So the desired output: 00:00, 01:00, 02:00, 03:00,..., 22:00, 23:00 like below image: I tried following code but no result: profiles = UserProfile.objects.filter(username=username) initial_formset = [{ 'user': item.name, 'time': datetime.datetime.now(). + datetime.timedelta(hours=1), } for item in profiles] MyFormset = formset_factory(MyForm, extra=24) formset = MyFormset(initial=initial_formset) Any help will be appreciated. -
can't multiply sequence by non-int of type 'QuerySet' in Django 2.2.4
I have this logic in my views.py that will multiply the quantity and unitprice in the same models. I am using aggregate, and i encountered this error, can't multiply sequence by non-int of type 'QuerySet' def updatecart(request): itemID = request.GET.get("itemID") cart = CustomerPurchaseOrderDetail.objects.filter(id = itemID) per_item_amount = CustomerPurchaseOrderDetail.objects.filter(id = itemID).aggregate(total=Sum('unitprice' * cart.values_list('quantity'))) print(per_item_amount) return render(request, 'customAdmin/add2cart.html', {"cart": cart}) this is my models.py class CustomerPurchaseOrderDetail(models.Model): profile = models.ForeignKey(Customer,on_delete=models.SET_NULL, null=True, blank=True,verbose_name="Client Account") customer_Purchase_Order = models.ForeignKey(CustomerPurchaseOrder, on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Customer Purchase Order") products = models.ForeignKey(Product,on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Product") quantity = models.IntegerField(null=True, blank=True, default=1) unitprice = models.FloatField(max_length=500, null=True, blank=True) def __str__(self): suser = '{0.id}' return suser.format(self) How do i configure this out? this is my traceback Traceback: File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\User\Desktop\LastProject\OnlinePalengke\customAdmin\views.py" in updatecart 981. per_item_amount = CustomerPurchaseOrderDetail.objects.filter(id = itemID).aggregate(total=Sum('unitprice' * cart.values_list('quantity'))) Exception Type: TypeError at /updatecart/ Exception Value: can't multiply sequence by non-int of type 'QuerySet' -
End of script output before headers: ezstage.wsgi
I am getting to only specific requests from django admin page which has big data wsgi.conf file <VirtualHost *:8080> WSGIPassAuthorization On #Header set Access-Control-Allow-Origin "*" WSGIScriptAlias / /home/ubuntu/ezstage.wsgi WSGIDaemonProcess localhost processes=4 threads=30 display-name=%{GROUP} WSGIProcessGroup localhost WSGIApplicationGroup %{GLOBAL} # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn LogLevel debug ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /static /home/ubuntu/criterioncloudez/static/ #Alias /static/admin /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/ <Directory /home/ubuntu> AllowOverride All Require all granted </Directory> <Location "/static/"> Options -Indexes </Location> ezstaze.wsgi file import os import sys import site prev_sys_path = list(sys.path) site.addsitedir('/usr/local/lib/python2.7/site-packages') sys.path.append('/home/ubuntu/criterioncloudez'); os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' sys.path.extend([ '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/django/contrib/admindocs', ]) new_sys_path = [p for p in sys.path if p not in prev_sys_path] for item in new_sys_path: sys.path.remove(item) sys.path[:0] = new_sys_path from django.core.wsgi import get_wsgi_application application = get_wsgi_application() ''' error: [Mon Aug 31 05:23:47.955596 2020] [authz_core:debug] [pid 31414] mod_authz_core.c(802): [client 117.216.179.95:15666] AH01626: authorization result of Require all granted: granted [Mon Aug 31 05:23:47.955647 2020] [authz_core:debug] [pid 31414] mod_authz_core.c(802): [client 117.216.179.95:15666] AH01626: authorization result of : granted [Mon Aug 31 05:23:47.962028 2020] [authz_core:debug] [pid 31414] mod_authz_core.c(802): [client 117.216.179.95:15666] AH01626: authorization result of Require all granted: granted [Mon … -
Create flask modules and dividing application
I'm building a small flask application and I want to have a modular structure in my project. In Django I could just write two separate folders with their own urls.py, register them in my settings.py and create routes to them in base urls.py. How to achieve this kind of modularity in flask? Preferably with as little code as possible. Bonus points if all this can be easily done without extensions. -
Returning httpresponse with queryset for ListView after post in Django
I have a listview with formmixin after submitting the form I was trying to return the exact same view with some extra messages, but I havent been able to return the query set, hence the list is not appearing, Can anyone pls help me. Views.py class NewsletterList(FormMixin, generic.ListView): queryset = newsletter.objects.filter(status=1).order_by('-created_on') template_name = 'newsletterlist.html' form_class = SubscriberForm def post(self, request, *args, **kwargs): form = SubscriberForm(request.POST) if form.is_valid(): sub = Subscriber(email=request.POST['email'], conf_num=random_digits()) sub.save() return NewsletterList.as_view()(request, queryset=newsletter.objects.filter(status=1).order_by('-created_on'),template_name='newsletterlist.html', form_class = SubscriberForm) Thanks in advance -
Display multiple list in django template
I have 10 lists of same lenght (20) with chained data meaning that A[0] is image for B[0] and C[0] but for the sake of smallest reproducible example i have 3 A=[image1, image2, image3, image4, image5, image6] B=[title1, title2, title3, title4, title5, title6] C=[name1, name2, name3, name4, name5 ,name6] I need to dispaly them in Django Templates like this: <div class="row"> <div class="col-4"> <div class="image"> image1 </div> <div class="title"> title1 </div> <div class="name"> name1 </div> </div> <div class="col-4"> <div class="image"> image2 </div> <div class="title"> title2 </div> <div class="name"> name2 </div> </div> <div class="col-4"> <div class="image"> image3 </div> <div class="title"> title3 </div> <div class="name"> name3 </div> </div> </div> and after this row is next one will be generated with the rest of the values How can i do this -
How to get data in the last 48 hours in Django?
I want to return the list of last points per vehicle that have sent navigation data in the last 48 hours. Since there may be a lot of data, I am looking for the most efficient and fast way to list. I wrote a function but encountered an error. AttributeError at / Manager isn't accessible via NavigationRecord instances How can I fix this error? Is there a more afformative and efficient way for me to do this listing? models.py class Vehicle(models.Model): id = models.IntegerField(primary_key=True) plate = models.CharField(max_length=30) class NavigationRecord(models.Model): id = models.IntegerField(primary_key=True) vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE) datetime = models.DateField() latitude = models.FloatField() longitude = models.FloatField() views.py def get_48_hours(request, id): time_48 = datetime.now() - timedelta(hours=48) navs = get_object_or_404(NavigationRecord, id=id) results = navs.objects.filter(date_created__gte=time_48) context = { 'navs': navs, 'results': results } return render(request, 'navigation.html', results) traceback Environment: Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 2.2.13 Python Version: 3.7.0 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'navigation'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "C:\Users\edeni\senior\myenv\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\Users\edeni\senior\myenv\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "C:\Users\edeni\senior\myenv\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\edeni\senior\evreka\navigation\views.py" in get_48_hours 10. results = … -
How to fix the problem of not showing the sitemap in django?
I created a sitemap as follows, but nothing is displayed inside the sitemap URL. How can I fix the problem? Thank you setting.py INSTALLED_APPS = [ 'django.contrib.sitemaps', ] sitemaps.py from django.contrib.sitemaps import Sitemap from django.shortcuts import reverse from riposts.models import Posts class RiSitemap(Sitemap): priority = 0.5 changefreq = 'daily' def get_queryset(self): posts = self.kwargs.get('posts') return Posts.objects.filter(status="p") def lastmod(self, obj): return obj.updated def location(self, item): return reverse(item) urls.py from django.contrib.sitemaps.views import sitemap from .views import home_page from riposts.sitemaps import RiSitemap sitemaps = { 'posts':RiSitemap, } urlpatterns = [ path('', home_page, name="home"), path("sitemap.xml", sitemap, {"sitemaps": sitemaps}, name="sitemap"), ] sitemap image -
Pagination for only one specific method of ModelViewSet Django Rest Framework
I have a class class Home(viewsets.ModelViewSet): serializer_class = HomeSerializer queryset = Home.objects.all() @action(detail=False, methods=['get']) def blog_data(self, request): queryset = Blogs.objects.filter(identifier='blog') serializer = BlogDataSerializer(data=queryset, many=True) #other serializer specific to this method serializer.is_valid() return Response(serializer.data) # need pagination here for this method only def list(self, request): .... return Response(serializer.data) i have overwritten list method and i only want pagination in blog_data method to have pagination with page_size and page_number(page) to be given as query params. example: http://localhost:8000/home?page=1&page_size=5 how would i acheive it, i have read about pagination_class = HomePagination but i dont want it to impact list method or any other method in this class, i only want pagination in my blog_data method pagination.py is class HomePagination(PageNumberPagination): page_size_query_param = 'page_size' def get_paginated_response(self, data): response = { 'no_of_records': self.page.paginator.count, 'no_of_pages': self.page.paginator.num_pages, 'page_size': int(self.request.GET.get('page_size')), 'page_no': self.page.number, 'results': data } return Response(response, status=status.HTTP_200_OK) -
How to correctly use validation messages in Django Models
In my Django app I am using a PositiveSmallIntegerField in one of my models wherein the minimum value for the field has been specified as under: trc_frequency = models.PositiveSmallIntegerField(default=1, validators=[MinValueValidator(1)], ...) Now what is happening is, when a value less than 1 (zero or a negative value) is being input in the form, the error message put forth by the system is to the effect: Ensure this value is greater than or equal to 0. Whereas, since the the minimum value defined for the field is "1" (one), I would prefer that the message informs the user that the minimum allowable value for the field is 1 (One), to the effect: Ensure this value is greater than or equal to 1. What I have tried so far: trc_frequency = models.PositiveSmallIntegerField(default=1, validators=[MinValueValidator(1, _('Must ensure this value is greater than or equal to %(limit_value)s.'))],...) But still getting the minimum value specified in the error message as 1 (Zero). Even more surprisingly, the message text also is not getting changed from Ensure this value is ... to Must ensure this value is... Why? Where am I going wrong. -
MySQL (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"
I can't access to MySQL since yesterday. ❯ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) I've tried several things to fix, but don't have any clue yet. First Try ❯ find / -name mysql.sock find: /usr/sbin/authserver: Permission denied find: /usr/local/var/mysql: Permission denied …. ❯ mysql -u root -p mysql S/var/local/var/mysql/mysql.sock mysql Ver 8.0.19 for osx10.14 on x86_64 (Homebrew) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. I could see some messages, but can not access to MySQL. Second try I found mysql.sock file in "/var/mysql/mysql.sock" So I edited my.cnf file, but it didn't work. ❯ vi /usr/local/etc/my.cnf #my.cnt [client] socket = /var/mysql/mysql.sock [mysqld] socket = /var/mysql/mysql.sock ❯ ln -s /tmp/mysql.sock /var/mysql/mysql.sock ln: /var/mysql/mysql.sock: File exists And there are other informations to try to fix. ❯ ls -l /tmp/mysql.sock lrwxr-xr-x 1 seungholee wheel 31 8 30 18:45 /tmp/mysql.sock -> /usr/local/bin/mysql/mysql.sock -
How to do I Architect my Website Builder using Django and React
I am planning to make a website builder of my own using which a user can generate websites based on a category they like . I am using django rest framework to handle the backend part in django and send data in api format to the front end. I am using ReactJS to render the components in Frontend. I am Very much confused regarding the architecture of the Project. Should i be storing the React/ Html components in the database or Should I Declare a Few React Components and pass the parameters which is returned for a particular site -
Cant split template django
I cant split string in my django template: {% with list.list|split:"%%_next_done=TRUE%%" as array %} {% for string in array %} <p>{{ string }}</p><br> {% endfor %} {% endwith %} Error: Invalid filter: 'split' -
on making migrations giving error django.db.utils.IntegreityError: (1364,"Field 'name' doesnt have a default value")
I was actually working on sqlite3 before where my django admin was working properly. but recently i shifted to mysql(cloud cluster). Ran all migrations python manage.py makemigrations python manage.py migrate sessions python manage.py migrate auth python manage.py migrate migrate its giving me error - ProgrammingError at /admin/login/ (1146, "Table 'databasename.auth_user' doesn't exist") when i am putting my previous superuser id and password when i recheck migrations - migrations is giving me error django.db.utils.IntegreityError: (1364,"Field 'name' doesnt have a default value") kindly help me making django admin work properly with my new database