Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django fixtures with specific data
I have an app with 3 models that refer to each other in a parent-child way: class A(Model): # ... class B(Model): a = ForeignKey(A) # ... class C(Model): b = ForeignKey(B) # ... In my production database, I have hundreds objects of type A, with thousands of child objects below it. I now want to create a fixture for only a (specific) handful objects. If I run this command, my output will become huge: python manage.py dumpdata ca_myapp -o /tmp/my_app_dump.json However, when I restrict the output using this command: python manage.py dumpdata ca_myapp.A -o /tmp/myapp_dump.json --pks pk1, pk2, pk3 Then only the A objects are deserialized, but not their children. How can I easily create a fixture file with a handful of objects and their children? -
django 1.11 Cannot extend templates recursively when using non-recursive template loaders
I have django 1.11.2 and I instaled django-mobile=0.7.0. When I want to go to admin panel I recive an error: ExtendsError at /admin/ Cannot extend templates recursively when using non-recursive template loaders Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.11.2 Exception Type: ExtendsError Exception Value: Cannot extend templates recursively when using non-recursive template loaders I recive an error in first line {% extends "admin/base.html" %} {% extends "admin/base.html" %} {% load admin_static %}{% load suit_tags %} {% block branding %} {% endblock branding %} My templates settings: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'templates'), ], 'APP_DIRS': False, 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.template.context_processors.csrf', 'django.template.context_processors.request', 'django.contrib.messages.context_processors.messages', 'django_mobile.context_processors.flavour', ], 'loaders': ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'django.template.loaders.eggs.Loader', 'django_mobile.loader.Loader', ), 'debug': DEBUG, }, }, ] TEMPLATE_LOADERS = TEMPLATES[0]['OPTIONS']['loaders'] Middleware classes: MIDDLEWARE_CLASSES = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django_mobile.middleware.MobileDetectionMiddleware', 'django_mobile.middleware.SetFlavourMiddleware', ] -
django oscar commerce: Conflicting 'stockrecord' models in application
I am using oscarcommerce for my django project. I want to extend the "StockRecord" model to include some more fields. So I forked the partner app as follows. (boscar is my app name) python manage.py oscar_fork_app partner boscar/ It successfully forked and new files were added to boscar/partner folder. I added 'boscar.partner' in my installed apps. Now I added new fields in StockRecord models as follows boscar/partner/models.py from django.db import models from oscar.apps.partner.abstract_models import AbstractStockRecord class StockRecord(AbstractStockRecord): effective_price = models.FloatField(default=0, null=True) is_instock_item = models.BooleanField(default=False, null=True) instock_quantity = models.IntegerField() from oscar.apps.partner.models import * # noqa Now when I try to make migrations it shows the following error. RuntimeError: Conflicting 'stockrecord' models in application 'partner': <class 'oscar.apps.partner.models.StockRecord'> and <class 'boscar.partner.models.StockRecord'>. I already successfully forked the catalogue and order models and that are working fine. Only this "StockRecord" models showing this error. -
How input date in my template ListView (request.POST.get) in Django
I have a class jourListView(ListView). I want to input date in my html template and then retrieve the date to make a filter. My class jourListView(ListView) refers to two linked tables. I am stuck at level. How to make my code functional? here are my models, views and template. class jour(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE, related_name='jour') date = models.DateField(blank=True, null=True) commentaire = models.CharField(max_length=500, blank=True, null=True) class Meta: managed = False db_table = 'jour' unique_together = (('id'),) verbose_name = 'JOUR' verbose_name_plural = 'JOUR' id = models.AutoField(primary_key=True) def get_absolute_url(self): return reverse("jour_detail",kwargs={'pk':self.pk}) def __str__(self): return str(self.date) ## class activite(models.Model): jour = models.ForeignKey('blog.jour',on_delete=models.CASCADE, related_name='jour' ) name= models.CharField(max_length=500, blank=True, null=True) class Meta: managed = False db_table = 'activite' unique_together = (('id'),) verbose_name = 'ACTIVITÉ' verbose_name_plural = 'ACTIVITÉ' id = models.AutoField(primary_key=True) def __str__(self): return self.type def get_absolute_url(self): return reverse("jour_list") My view: class jourListView(ListView): model = jour def get_context_data(self, **kwargs): if request.method == 'POST': date_insert = request.POST.get('date_ref') context = super(jourListView, self).get_context_data(**kwargs) context['count'] = self.get_queryset().count() return context def get_queryset(self): return jour.objects.filter(date__lte=timezone.now()).filter(user=self.request.user).filter(date__in=date_insert) My html template: {% if user.is_authenticated %} <div class="container text-center"> <form class="form-signin" id="login_form" method="post" action="/blog/list/"> {% csrf_token %} <br> <input type="date" name="date_ref" class="form-control" placeholder="SAISIE DATE " value="" required autofocus> <br> <button class="btn btn-lg btn-primary btn-block" type="submit">OK</button> </form> </div> … -
Is there a way to find where a line code is executed?
I'm using python 3.5 and downloaded an updated version of my project from bitbucket. When I try to makemigrations I get: django.core.exceptions.FieldDoesNotExist: users.user has no field named 'surname' Is there a way to find where this is executed? Because in my models.py I have users.lastname. Thank you in advance! -
Loading images as base64 calls from Javascript
I am trying to implement a small photo show via a django webserver. Below you can find the javascript code that loads the pictures into the images array and changes the images every x miliseconds. It works if I only load one picture (without the loop) from my django server but it stops working with any kind of loop. I would love to know why it does not work this way and would be more than happy to receive some other feedback about code improvements. I am not very familiar with ajax calls yet. Moreover: Django Templates Engine provides a easy way to simplify urls used in the templates. Is there a way to use the {{% url %}} tag inside a .js File as well? window.images = []; window.current = 0; window.imageCount = 2; function loadImages(){ for(var i = 0; i < window.imageCount; i++){ loadNextImage(i); } showImage(); } function loadNextImage(i) { // https://wiki.selfhtml.org/wiki/JavaScript/XMLHttpRequest/ var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { window.images.push("data:image/jpeg;base64," + xmlhttp.responseText); } }; xmlhttp.open('GET', "http://127.0.0.1:8000/mirror/"+i); xmlhttp.send(null); } function showImage() { if(window.current >= window.imageCount){ window.current = 0; } alert("current window count = "+ window.current); document.getElementById('imgshow').src = window.images[window.current]; … -
Is there an equivalent for _collect_sub_objects method in Python 3?
I'm trying to implement a method that duplicate Django model instances and its related objects. The solution is in this stackoverflow post. But _collect_sub_objects method seems to be deprecated in python 3. Somebody could tell me if its a new version in recent versions of python? -
Getting credential using GoogleAPI - HttpResponseRedirect status_code=302
I get this error : HttpResponseRedirect' object has no attribute 'authorize' I've printed HttpResponseRedirect object and I have something like this: HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="https://accounts.google.com/o/oauth2/auth?client_id=..." I've copied this url to my browser and it does work. When I run app locally everything works fine, but now I moved my app to pythonanywhere recently and it stopped working. Here is my code: def get_credentials(user): home_dir = os.path.expanduser('~') home_dir = BASE_DIR + '/oauth2/' + user.username credential_dir = os.path.join(home_dir, '.credentials') if not os.path.exists(credential_dir): os.makedirs(credential_dir) credential_path = os.path.join(credential_dir, 'calendar-python-quickstart.json') storage = Storage(credential_path) credentials = storage.get() if not credentials or credentials.invalid: print(True) FLOW = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES,redirect_uri="http://XXXXXX.pythonanywhere.com/accounts/google/login/callback/") FLOW.params['state'] = xsrfutil.generate_token(SECRET_KEY, user) authorize_url = FLOW.step1_get_authorize_url() return HttpResponseRedirect(authorize_url) return credentials class EventTeamToggleAPI(LoginRequiredMixin, APIView): authentication_classes = (authentication.SessionAuthentication,) permission_classes = (permissions.IsAuthenticated,) def get(self, request, *args, **kwargs): self.slug = self.kwargs.get('slug') team = get_object_or_404(Team,slug=self.slug) updated = False added = False user_other_teams = Team.objects.filter(user_team_events=self.request.user).exclude(pk=team.pk) games = Game.objects.filter(Q(team_home=team) | Q(team_away=team)) if self.request.user.google_cal==True: credentials = get_credentials(self.request.user) http = credentials.authorize(Http()) service = build('calendar', 'v3', http=http) {...} return(...) Can someone explain to me what is the problem ? Thanks -
unit tests returning True when using python requests even if DB entry is empty
Recently I've tried using requests to make requests to my local server then use django's unittests to test whether or not they are there. I know usually unittests makes temp database entries then tests those, but I want to test my actual project DBs so I used requests. Problem is for the vader entry it should return false (so I think) because it's missing the conversation_id key. Therefore it doesn't get entered into the DB (I checked it's not there). The Luke entry is there (as it should be). So why is the vader entry returning True? Is it still sending to a temp DB? import requests from django.test import TestCase from convoapp.models import InputInfo from django.urls import reverse import sqlite3 def add_message(request): fields = ['name', 'conversation_id', 'message_body'] if request.method == 'POST': form = InputInfoForm(request.POST) #validate/ DB won't update if form is invalid if form.is_valid(): InputInfo.name = request.POST.get('name') InputInfo.conversation_id = request.POST.get('conversation_id') InputInfo.message_body = request.POST.get('message_body') form.save() else: form = InputInfoForm(request.POST) return render(request, 'blank.html') class InputInfoTestCase(TestCase): def setUp(self): post_request = requests.session() post_request.get('http://127.0.0.1:8000/message/') csrftoken = post_request.cookies['csrftoken'] luke_data = {'name': 'Luke', 'conversation_id': '1', 'message_body': 'I am a Jedi, like my father before me','csrfmiddlewaretoken' : csrftoken} vader_data = {'name': 'Vader', 'message_body': 'No, I am your … -
Django with Gspread and OAuth breaks POST
For a project in Django, we're using Gspread to get data from a spreadsheet and OAuth for authentication. However, since OAuth has been added, POST stops working. The Trainig class with post(): class TrainingList(APIView): permission_classes = (IsAuthenticated,) def get(self, request): worksheet = get_sheet(request.GET.get('sheet', 'Data')) list_of_records = worksheet.get_all_records() return JsonResponse(list_of_records, safe=False, status=status.HTTP_200_OK) def post(self, request): worksheet = get_sheet(request.GET.get('sheet', 'Data')) data = json.loads(request.body.decode('utf-8')) if validate_data_has_all(data): worksheet.append_row( [data["date"], data["days"], data["firstname"], data["lastname"], data["team"], data["training"], data["company"], data["city"], data["cost"], data["invoice"], data["info"]]) return JsonResponse(data, safe=False, status=status.HTTP_201_CREATED) else: return JsonResponse([], safe=False, status=status.HTTP_400_BAD_REQUEST) And the traceback: Traceback (most recent call last): File "C:\Python\backend\env\lib\site-packages\django\core\handlers\exception.py", line 35, in inner response = get_response(request) File "C:\Python\backend\env\lib\site-packages\django\core\handlers\base.py", line 128, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Python\backend\env\lib\site-packages\django\core\handlers\base.py", line 126, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Python\backend\env\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "C:\Python\backend\env\lib\site-packages\django\views\generic\base.py", line 69, in view return self.dispatch(request, *args, **kwargs) File "C:\Python\backend\env\lib\site-packages\rest_framework\views.py", line 489, in dispatch response = self.handle_exception(exc) File "C:\Python\backend\env\lib\site-packages\rest_framework\views.py", line 449, in handle_exception self.raise_uncaught_exception(exc) File "C:\Python\backend\env\lib\site-packages\rest_framework\views.py", line 486, in dispatch response = handler(request, *args, **kwargs) File "C:\Python\backend\unleashedapp\trainings\views.py", line 60, in post data = json.loads(request.body.decode('utf-8')) File "C:\Python\backend\env\lib\site-packages\rest_framework\request.py", line 385, in __getattribute__ return getattr(self._request, attr) File "C:\Python\backend\env\lib\site-packages\django\http\request.py", line 255, in body raise RawPostDataException("You cannot access body after reading from … -
Django multibase administration site
I newbe in Django, so excuse me for question, but I can't find solution. I try to work with multibases. f.ex. (sqlite3). First of it is default (in file db.sqlite3) and second is 'depend' in file depend.sqlite3. I set something in settings.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'depend': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'depend.sqlite3'), } } and after: python manage.py inspectdb --database 'depend' > models.py and change column-key, I have: from django.db import models class AllFiles(models.Model): db_id = models.IntegerField(primary_key=True) filename = models.CharField(max_length=100, blank=True, null=True) ... my router.py states now: class AuthRouter: """ A router to control all database operations on models in the auth application. """ def db_for_read(self, model, **hints): """ Attempts to read auth models go to auth_db. """ if model._meta.app_label == 'depend': return 'depend' return None ... and next I add my 3 tables from new DB into admin-site with: admin.site.register(models.AllFiles) admin.site.register(models.ImportingDict) admin.site.register(models.InputDir) when server (localhost:8000) is running, and admin is logged, I have in admin-view (http://localhost:8000/admin/) 3 new position with 3 new tables, but when try do something with one of them, get: Exception Type: OperationalError Exception Value: no such table: all_files what I missing? what is wrong? Should I register … -
How make an admin action enabled or works just one time a year?
I need to make an admin action enabled or works just one time a year is this possible Here is the action : def update_vacations(modeladmin, request, queryset): for item in queryset: item.calculconge = item.calculVacation + item.VacationDays item.save() update_vacations.short_description = "Update Vacations" -
Merging multiple querysets in Django Rest Framework
How can you merge querysets in Django? I use the Django Rest Framework. I work with the following model: class City(models.Model): ... class House(models.Model): city = models.ForeignKey(City, ...) ... class Resident(models.Model): house = models.Foreignkey(House, ...) ... I now want to have a view that lists all the residents of a given city (slug is the slug of the city). Here is how I wrote it: class ResidentList(generics.ListAPIView): lookup_field = 'slug' serializer_class = ResidentSerializer permission_classes = (IsAuthenticated, IsMayor) def get_queryset(self): residents = Resident.objects.filter(house__city__slug=self.kwargs['slug']) return residents As you can see I create the list of residents for a city by iterating through all the citizens and filter those who life in a home that lifes in the right city. I just feel like this is pretty bad and inefficient, since the database has to loop through ALL the citizens. It would be better to have something like City.objects.get(slug=<cityslug>).houses.residents Then I would only have to loop through the smaller amount of cities. The problem with this obviously is that the above query returns a queryset. Therefore I can't chain houses and residents like that. Any help would be much appreciated! :) PS: If you have other suggestions how I can improve my view … -
AllowAny for get method in djangorestframework
I use django rest framework, example code class TestApiView(APIView): def get(self, request): return Response({'text': 'allow any'}) def post(self, request): return Response({'text': 'IsAuthenticated'}) how to make method get allow any, method post only authenticated thank you in advance -
WebSocket connection to 'ws:url' failed: WebSocket is closed before the connection is established
I am pretty new to Django Channels and when i went through some tutorials i came across this project Channels Examples.When i run the project in my system, i get the following error. 127.0.0.1:56653 - - [20/Feb/2018:17:18:37] "GET /new/" 302 - 127.0.0.1:56653 - - [20/Feb/2018:17:18:38] "GET /royal-dawn-8676/" 200 1865 127.0.0.1:56653 - - [20/Feb/2018:17:18:38] "GET /static/chat.js" 304 - 127.0.0.1:56669 - - [20/Feb/2018:17:18:38] "WSCONNECTING /chat/royal-dawn-8676/" - - 127.0.0.1:56669 - - [20/Feb/2018:17:18:40] "WSDISCONNECT /chat/royal-dawn-8676/" - - 127.0.0.1:56677 - - [20/Feb/2018:17:18:41] "WSCONNECTING /chat/royal-dawn-8676/" - - 127.0.0.1:56677 - - [20/Feb/2018:17:18:43] "WSDISCONNECT /chat/royal-dawn-8676/" - - 127.0.0.1:56680 - - [20/Feb/2018:17:18:45] "WSCONNECTING /chat/royal-dawn-8676/" - - 127.0.0.1:56680 - - [20/Feb/2018:17:18:47] "WSDISCONNECT /chat/royal-dawn-8676/" - - Note: My Django Version -1.11.8, Channels Version-1.1.6 -
How do I invoke a lambda function inside a views function in Django?
I have a Django views to create a sort of AWS pack (contains account and new vpc creation), I am trying to invoke a lambda function in between that will delete the default vpc in the newly created account. Here is my snippet : def createlab(request): if request.method == 'POST': lab_name = request.POST.get('labname') cidr = request.POST.get('cidr') bill = request.POST.get('budget') email = request.POST.get('email') #CREATE ACCOUNT org = boto3.client('organizations') acc = org.create_account( Email=email, AccountName=lab_name, IamUserAccessToBilling='ALLOW' ) time.sleep(35) cid = acc['CreateAccountStatus']['Id'] #GET ACCOUNT DETAILS status = org.describe_create_account_status( CreateAccountRequestId=cid ) print(status) time.sleep(17) while True: status = org.describe_create_account_status(CreateAccountRequestId=cid) try: accid = status['CreateAccountStatus']['AccountId'] break except KeyError: time.sleep(40) accid = status['CreateAccountStatus']['State'] #CREATE VPC session = boto3.Session (aws_access_key_id=acc_key, aws_secret_access_key=sec_key,aws_session_token=token) ec2 = session.resource('ec2',region_name=region_ec2_sub) vpc = ec2.create_vpc(CidrBlock=cidr) id = vpc.id #DELETE DEFAULT VPC client = boto3.client('lambda',region_name='us-west-2') deletevpc= client.invoke(FunctionName='default_vpc', InvocationType='RequestResponse') print (deletevpc) I have included a portion of my views function. I have added the #DELETE DEFAULT VPC snippet in the end. The lambda function is not getting executed. What am I doing wrong here ? -
Django, Markdown and SageCell
I am building a blog with Django. This blog is made up by posts whose content would benefit a lot from using Markdown syntax. But some of this posts also include SageMath cells, which process some Python-Sage Code enclosed in some special divs, as in this tutorial. Now every Markdown engine parses the Python code, and both tools (Markdown and SageMath) come into conflict. Which would be smartest approach for implementing these posts? -
Error in installing pypiwin32
I wanted to parse *.msg file with python and I need to import win32com.client in python programming. Then it is giving me that this module is not defined then I am trying to install pip install pypiwin32 I am using ubuntu 17.10 and it is giving me error import _winreg ImportError: No module named _winreg I am also attaching the screenshot for a better understanding of the problem. is this only for windows, I am highly confused. Some other way of parsing the .msg file with python would also be appreciated. Please help me out.First attachment of code Error screenshot -
Add non-model field in Serializer DRF
I trying to combine rasters model field with non-model config_version field into my serializer which looks like: class RasterPostSerializer(serializers.ModelSerializer): class Meta: model = Raster fields = ( 'name', 'description', 'filepath' ) class ConfigurationSerializer(serializers.Serializer): config_version = serializers.CharField() rasters = RasterPostSerializer(many=True) def create(self, validated_data): data_field = validated_data['rasters'] for raster in data_field['rasters']: return Raster(name=raster['name'], description=raster['description'], filepath=raster['filepath']) Before utilize serializer.save() method I would like to check config_version in my view.py, but after that the .save() gives me: The serializer field might be named incorrectly and not match any attribute or key on the `Raster` instance. Original exception text was: 'Raster' object has no attribute 'config_version'. What is going on, and is there a solution for that? -
PostgreSQL ArrayField is too slow in Django
I'm performing the following query in my Django project: for obj in Path.objects.filter(Q(server_name__exact=name), Q(keywords__overlap=all_words)): The field keywords is an ArrayField and I'm using the overlap filter which is equivalent to something like following in python: keywords.intersection(all_words) # if keywords is a set Now the problem is that when all_words is a small list, less than 10, it does the job very fast but when all_words is a larger array, more than 20-30, it takes so much time. Is there any way around this? I tested other ways like the following but it's didn't make any different. for obj in Path.objects.filter(server_name=name): if all_words.intersection(keywords__overlap): -
Django don't create new sqlite table for new app model
pretty new to Django, i'm encountering an issue with a new model (and a new app 'blog' i made). The table blog_post didn't exist after configuring the model and makemigration. Here is the all process i did. I'm following official tutorial: Here is my blog/models.py: from django.db import models class Post(models.Model): title = models.CharField(max_length=80) text = models.TextField() author = models.ForeignKey('auth.User', on_delete= models.CASCADE) created_date = models.DateTimeField() pub_date = models.DateTimeField() def publish(): self.pub_date = timezone.now() self.save() mysite/settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog.apps.BlogConfig', ] After the first python manage.py makemigrations blog Migrations for 'blog': blog\migrations\0001_initial.py - Create model Post python manage.py sqlmigrate blog 0001 BEGIN; -- -- Create model Post -- CREATE TABLE "blog_post" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "title" varchar(80) NOT NULL, "text" text NOT NULL, "created_date" datetime NOT NULL, "pub_date" datetime NOT NULL, "author_id" integer NOT NULL REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED); CREATE INDEX "blog_post_author_id_dd7a8485" ON "blog_post" ("author_id"); COMMIT; python manage.py migrate Operations to perform: Apply all migrations: admin, auth, blog, contenttypes, sessions Running migrations: No migrations to apply. So, here it is. The new table didn't seem to be created. I check with a SqLite utility and the is no such table: … -
Django channel vs node socket.io
I want to develop a real time chat application and also want to show real time graph/chart.I am confused to choose technology.I heard a lot of good things about nodejs socket.io and also heard about django channel.Can you suggest me to choose from one of them for my project? There need a special feature though.I need to run a cron job to get data from external web service and broadcast it to all clients. Thanks in advance -
How to change table object name in django?
I have a table named Product. Every time I create a object using the table django automatically names it as Product object(1), Product object(2) and so forth. Instead of Project object(1) I want to name it something creative. In my Product Table I have a field called Product Name. Whatever I insert into this field I want that to be the name of the object. If I insert Pen, it should simply show Pen not Product object(1) or anything like that. I am attaching a picture so you guys can understand my problem clearly. -
ImportError: No module named 'basic' in Python
First of all, I am a Django rookie, so pls get that. I am trying to set up local enviroment, so I can run a web page locally on a VM. But I am getting ImportError: No module named 'basic' in Python error, no matter if I'm trying to run as su or not. Django version is 2.0.2 Python is 3.4.3 This is my output -
OTP authentication in Django and Populate model data with Sql data
I am working on assignment given to me, and this is the requirement: Customise the Django User Table Instructions: Modify the default Django user table and the custom user table should consist of the following fields. First Name Last Name Gender Email ID (Primary Key) Phone Number There is no “password” field. The password to login will be an OTP either sent to their mail or Phone Number. Write Rest APIs for Signup, Login, Logout. Create HTML pages for the same. Every time a user tries to Login, OTP is sent and he has to use that OTP to login. Use the given sql dump (world.sql) to create the other models and to populate the data. This will give you the data to display once the user logs in. On login, the dashboard with just one search bar and search button should be displayed. (refer google home page) As user starts typing in the search bar, the system should autosuggest options available in the system. The user will search by city or country or language. Once search button is pressed, list of relevant information should be displayed in the next screen. Where ever the name of a country appears, it …