Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Error template when using {%djng_all_rmi %} - django + AngularJs
I'm using django 1.1.10 with Angularjs to developping my first app . according to this document : http://django-angular.readthedocs.io/en/latest/remote-method-invocation.html when using this code : {% load djng_tags %} … <script type="text/javascript"> var tags = {% djng_all_rmi %}; my_app.config(function(djangoRMIProvider) { djangoRMIProvider.configure(tags); }); </script> i get this error : enter image description here Thanks for your help ! -
AttributeError: object has no attribute 'ordered' when iterating a dictionary of lists of formsets
I have A dictionary called FormDic. The Values of the dictionary are lists and the lists contain formsets. I have double checked that this is the case 100 different ways. In my template i have the following: {% for key, ItemList in FormDic.items %} {% for Formset in Itemlist %} xxxxx {% endfor %} {% endfor %} the x's are just placeholder. Now if I refer to the formset in any way, {{Formset}} {{Itemlist.0}}, whatever.... it throws a AttributeError: 'Item' object has no attribute 'ordered' Any help would be appreciated. I'm losing my mind on this. Thx -
Django - Session expiration renewal
I'm just getting interested in making web apps with Django and I'm struggling with a question about sessions. I wonder how to make a session expire if the user has not tried to connect to the website in a certain period of time (15 days for exemple). In other words, I would like to renew the expiration date of a user session each time he/she is connecting to the site. I scrapped a lot of websites but I couldn't find any valuable example. -
Iterate Over Object GET Request Python
We are working with Django to GET sales data from a server for a number of brands. The endpoint is below and requires an API key and password. API keys and password for each brand are stored in settings.py. How we pass through the brand name to the endpoint so that the data is pulled iteratively? brand = models.CharField(max_length=140) orders_endpoint = 'https://{api_key}:{password}@site.com/admin/orders/count.json?status=any' orders_url = orders_endpoint.format(api_key=settings.brand_API_KEY, password=settings.brand_PASSWORD) orders_response = requests.get(orders_url) orders_json = orders_response.json() orders = mark_safe(json.dumps(orders_json)) -
`docker up --build` yields ImportError: No module named django.core.management
I'm converting a working django application to run in Docker containers. #Dockerfile FROM python:3 RUN mkdir /code ADD . /code/ WORKDIR /code RUN pip3 -q install -r requirements.txt RUN ls $(python -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())") CMD python manage.py runserver the penultimate line prints out my site-packages and shows django as one of the installed modules. adding RUN pip3 freeze shows Django==1.11.4 which is what I'd expect. Given this, I can't explain why i'm getting the ImportError -
How to create a prepopulated form based on an existing object in Django's admin
I'm setting up links within a Django admin list view, where I want the links to redirect users to a prepopulated form based on the existing object that the link appears next to within the list form. So essentially these added links will act almost like a "create new" button with a form that is prepopulated with some of the data from the existing object. Is it possible to do this within the framework? Or will I need to add in JavaScript for this functionality? Currently I have these links for the list view added via the admin class in my admin.py file (without any functionality tied to them just yet): def get_link(self, obj): return u'<a href="/%s/copy">Copy</a>' % obj.id get_link.allow_tags = True get_link.short_description = "" And the URL pattern is set up for these copy pages like this: def get_urls(self): urls = super(MyAdmin, self).get_urls() custom_urls = patterns( '', ( r'^(?P<id>\d+)/copy/$', self.admin_site.admin_view(CopyView.as_view()) ), ) return custom_urls + urls -
Extracting a path variable from an included URL pattern in Django
Been scratching my head quite a bit with this one, can't seem to figure out what I am doing wrong. So, the problem is that I cannot seem to extract the path variable that I want from a urls.py inside an app to pass it to the function that should be called when the path is visited. This URL configuration where I am trying to get it is a nested one that is included when one visits events/, here is how it looks: Root URL configuration: urlpatterns = [ url(r'^api/', include(router.urls)), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^admin/', admin.site.urls), url(r'^events/', include(event_urls)) ] And then the included URL conf from event_urls: urlpatterns = [ url(r'alarm/<alarm>', alarm) ] Should be pretty straight forward I imagine, but the above does not work, like at all! If I construct the URLs in this way, requesting to the path events/alarm/on will state that path does not exist. After this, I figured it could not match the URL, but I don't understand why or how to fix it. I thought (from the docs) that the part would match anything! Now, I did some more investigating that proved to me that using a pattern for the might be the right … -
Is it a bad practice to use sleep() in a web server in production?
I'm working with Django1.8 and Python2.7. In a certain part of the project, I open a socket and send some data through it. Due to the way the other end works, I need to leave some time (let's say 10 miliseconds) between each data that I send: while True: send(data) sleep(10) So my question is: is it considered a bad practive to simply use sleep() to create that pause? Is there maybe any other more efficient approach? -
Django Memcache not setting value
I am using AWS Elastic Cache as a backend which uses memcache. What I am basically trying to do is apply throttling to DRF. Now it uses cache to keep track of requests. The throttling works fine if I use default Django Cache, but if I switch to memcache it doesnt. What I tracked to it that memcache stores cache_keys differently. So, I changed the make_keys method, but that didnt work either. Any Idea on how to fix this? -
How to protect concurrent write of same number in Django Tastypie
A REST API implemented with Tastypie, which is to write a number into a table. To prevent 2 users to write same number into the table, and is_valid() is implemented in HelloValidation. transaction.atomic() is used to prevent concurrent write. Models.py class HelloModel ... RestApi.py from django.db import transaction from tastypie import resources from tastypie import validation class HelloValidation(Validation): def is_valid(self, bundle, request=None): """Length validation.""" return status class HelloResource(ModelResource): class Meta(object): queryset = models.HelloModel.objects.all() validation = HelloValidation() def dispatch(self, request_type, request, **kwargs): with transaction.atomic(): response = super(HelloResource, self).dispatch(request_type, request, **kwargs) return response This is my understanding: 1) Without transaction.atomic(). If 2 user write same number at same time, is_valid() will be True. For example, table has 1 row with number 10, 2 users write same number 20. Each 'thread' read table with 10, and 20 is valid, as it is not same number as 10. There is no protection of writing same number. Is that correct? 2) I added transaction.atomic(), but I am not sure what it does in this case, because is_valid = True. Does transaction.atomic() lock the table? If it locks the table, is_valid() can't be performed currently for 2 users, then, I know following code work. But, I … -
Python manage.py runserver in Docker container not working
Inside my Docker container, in the root folder of my Django application, I activate a virtual environment, and run python manage.py runserver. I have exposed the ports 80 and 443 for the container, and at first glance it appears to be running >>> docker run -it <container> >>> cd .virtualenv >>> source bin/activate >>> cd .. >>> python manage.py runserver System check identified no issues (0 silenced). February 20, 2018 - 20:32:08 Django version 1.11.6, using settings 'sesttings.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. When I go to http://:8000 though the site can't be accessed, it just sits there and loads forever. I checked the logs using docker logs container_id, but there isn't anything in there. -
Upon stripe customer creation save Customer model on server
The stripe customer is being successfully created on stripes servers but I need a representation on my server so I created the Customer model all it has is the user_id and the stripe_id. Heres the code I have been trying but it does not work.. I think the problem is with retrieving the actual stripe id for that particular user.. # Create stripe customer stripe.Customer.create() new_customer = Customer( user=request.user, stripe_id=id, ) new_customer.save() This snippet of code is inside the user registration view, and it runs after the user is authenticated and logged in So what appears in the stripe_id field is: <built-in function id> -
Nginx serving Django in subdirectory - admin login is redirecting
I have to serve a Django app from a subdirectory (hostname/service/). So far I'm able to get to the Admin Login prompt (hostname/service/admin/login/), but after successfully logging in I'm redirected to (hostname/admin/login/) and get a 404. How can I keep the correct subdirectory and get inside the Admin panel? Here's the nginx.conf server block: server { listen 80; root /usr/share/nginx/html/; charset utf-8; location /service { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://djangoapp:8000/; proxy_set_header X-Real-IP $remote_addr; } location /static { alias /usr/src/app/static; } } -
Why do I lose connectivity to my SQL server when running through Apache?
I am trying to deploy my django project on my company LAN. I am able to get the site working, however, I lose connectivity to my Microsoft SQL Server when I run site through apache. Everything works fine in the development environment. I suspect it I am losing windows authentication when I work through the apache server. This is what my db settings are in my settings.py files: 'mosaiq': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'MOSAIQ', 'USER': '', 'PASSWORD': '', 'HOST': 'HHCMOSAIQ01T', 'PORT': '', 'OPTIONS': {'driver': 'ODBC Driver 11 for SQL Server', }, Any ideas how to connect to my sql server using windows authentication or does my problem lie elsewhere? -
Delete/Clear staticfiles cache in whitenoise
I cant seem to find how to refresh the whitenoise static files cache. It has been giving me a problem. Which has persisted even when I removed the specific file cause the problem. The Manifest is still referring to a missing removed staticfile. I would like to clear the cache so that it can be repopulated. -
multiple paginations in Django not working, getting redirected
I am struggling with this for a while now and I came close to something. I have four models bound to each other by foreign keys in this order: Faculty > Department > StudyProgramme > Courses. I created pagination with search for all of my courses. Now I wanted to create pagination for courses that belong to a specific faculty only. For example, I have a total of 3 courses, from which 2 belong to Informatics faculty and 1 belongs to Medicine faculty, and for each of those I need pagination by 1 course per page. After a lot of tries, I thought of using faculties id's as a way to make individual pagination, but no success.. All courses of a faculty get displayed, instead of just 1, and if I click next, I get redirected to the pagination of all courses. I don't know how to fix this: @login_required def index(request): query_list = Course.objects.all() query = request.GET.get('q') if query: query_list = query_list.filter(Q(name__icontains=query)) paginator = Paginator(query_list, 1) page = request.GET.get('page') faculty_id = request.GET.get('faculty_id') courses_to_display = None try: courses = paginator.page(page) except PageNotAnInteger: courses = paginator.page(1) except EmptyPage: courses = paginator.page(paginator.num_pages) if not faculty_id: courses_to_display = courses faculties = Faculty.objects.all() for … -
How to get a specific row by using the row number
I'm trying to make a function that will find the median value of a set. However, I don't know how to filter the queryset by row number. Code: Function: def getQuestion(attr): datatype = Attribute.objects.filter(attribute_name = attr).values('attribute_data_type') if datatype == 'BOOLEAN': return 'Is the object ' + attr + '?' if datatype == 'DOUBLE': temp = Object_Attribute.objects.filter(attribute_name = attr).order_by('attribute_double') hw = int hw = Object_Attribute.objects.filter(attribute_name = attr).count()/2 par return par Models: class Object(models.Model): object_number = models.IntegerField() object_name = models.CharField(max_length=200) def __str__(self): return self.object_name class Attribute(models.Model): attribute_number = models.IntegerField() attribute_name = models.CharField(max_length=200) attribute_data_type = models.CharField(max_length=200) attribute_range_low = models.DecimalField(max_digits=100, decimal_places=50, null=True, blank=True) attribute_range_high = models.DecimalField(max_digits=100, decimal_places=50, null=True, blank=True) def __str__(self): return self.attribute_name class Object_Attribute(models.Model): object_name = models.ForeignKey('Object', on_delete=models.CASCADE) attribute_name = models.ForeignKey('Attribute', on_delete=models.CASCADE) attribute_boolean = models.NullBooleanField(null=True, blank=True) attribute_double = models.FloatField(null=True, blank=True) attribute_string = models.CharField(max_length=200, null=True, blank=True) def __str__(self): return str(self.object_name) +'\'s ' + str(self.attribute_name) -
Project runs on Heroku locally, but not online
I was deploying my project to Heroku and tried locally with the te comand heroku local web. That works perfectly, but, when I sended the the project to run online, I got this error on Heroku logs: 2018-02-20T17:23:21.824637+00:00 heroku[web.1]: State changed from starting to crashed 2018-02-20T17:23:33.111420+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sagaedu.herokuapp.com request_id=b04299fc-6ea8-41d3-a994-9a064b6d98af fwd="177.39.172.28" dyno= connect= service= status=503 bytes= protocol=https 2018-02-20T17:24:03.282786+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sagaedu.herokuapp.com request_id=88a02575-95dc-4450-b9b4-e53f65770454 fwd="177.39.172.28" dyno= connect= service= status=503 bytes= protocol=https 2018-02-20T17:27:04.669222+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sagaedu.herokuapp.com request_id=c56fa212-d104-4569-b916-439e3d003398 fwd="177.39.172.28" dyno= connect= service= status=503 bytes= protocol=https 2018-02-20T17:32:00.954709+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sagaedu.herokuapp.com request_id=c8126dd0-0868-4d12-9421-2d2d7b94e73c fwd="177.39.172.28" dyno= connect= service= status=503 bytes= protocol=https 2018-02-20T17:35:16.000000+00:00 app[api]: Build started by user 2018-02-20T17:36:00.992071+00:00 heroku[web.1]: State changed from crashed to down 2018-02-20T17:36:00.794498+00:00 app[api]: Deploy 07a1f9df by user 2018-02-20T17:36:00.794498+00:00 app[api]: Release v15 created by user 2018-02-20T17:35:16.000000+00:00 app[api]: Build succeeded 2018-02-20T17:38:16.055964+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=sagaedu.herokuapp.com request_id=12e85de9-ac80-413c-b022-8f8fb91944aa fwd="177.39.172.28" dyno= connect= service= status=503 bytes= protocol=https -
django distinct in the ListViews
I am having an issue with a distinct in the ListViews I have a connection M2M between “Allergeni” and “Ingredient” and another one M2M between “Product” and “Ingredient” that goes through the table “Materiali”. I need to obtain a table with the whole list of “Product” with an extra field “Allergeni” that contains only a unique version for of all the values in the raw model for ingredients: class Ingredient (models.Model): nome = models.CharField(max_length=200) categoria = models.ForeignKey("Categoria") costokg = models.DecimalField(max_digits=20,decimal_places=2,default=Decimal('0.00')) resa = models.IntegerField() prezzopulito = models.DecimalField(max_digits=20,decimal_places=3,default=Decimal('0.00')) componenti = models.TextField() allergeni = models.ManyToManyField("Allergeni", blank=True) def __str__(self): return self.nome def get_absolute_url(self): return reverse("ingredients:detail", kwargs={"pk": self.pk}) class Allergeni (models.Model): allergene = models.CharField(max_length=100) model for products: class Product (models.Model): nome = models.CharField(max_length=250) descrizione = models.TextField(blank=True, null=True) prezzo = models.DecimalField(max_digits=20,decimal_places=2,default=Decimal('0.00')) peso_finale = models.DecimalField(max_digits=20,decimal_places=2,default=Decimal('0.00')) categoria = models.ForeignKey("Categoria") tag = models.ManyToManyField("Tag", blank=True) componenti = models.ManyToManyField(Ingredient, through='Materiali', through_fields=('object_id', 'ingrediente')) creazione = models.DateTimeField(auto_now=False, auto_now_add=True) aggiornamento = models.DateTimeField(auto_now=True, auto_now_add=False) def __str__(self): return self.nome def get_absolute_url(self): return reverse("products:detail", kwargs={"pk": self.pk}) class Materiali (models.Model): object_id = models.ForeignKey("Product", on_delete=models.CASCADE) ingrediente = models.ForeignKey(Ingredient, on_delete=models.CASCADE, related_name="materia_prima") peso = models.DecimalField(max_digits=20,decimal_places=2,default=Decimal('0.00')) def __str__(self): return self.ingrediente.nome product view def product_list(request): queryset = Product.objects.all() \ .annotate(total=Round((Sum((F('materiali__ingrediente__prezzopulito')/1000) * F('materiali__peso'))) / (F('peso_finale'))) * 1000 ) materiali = Materiali.objects.all() allergeni= materiali.values_list('ingrediente__allergeni__allergene', flat=True).distinct() … -
Trouble rendering Images through Django templates using static tags and view.py request
I am trying to dynamically add images to my web page using Django templates. If is add the image name directly, the image is on the web page as expected: {% block content %} {% load staticfiles %} <img id='productImage' src="{% static 'buylist/img/images/image name.jpg' %}"> {% endblock %} instead of passing the name of the file directly, I want to pass the file name using my the name of the product in my database like: <img id='productImage' src="{% static 'buylist/img/images/{{product.name}}.jpg' %}"> But I guess I can't use template tags inside of static tags? When I do it this way and inspect the element on the webpage, I see that it rendered{{product.name}} as pure text, so of course it didn't find the image. I also tried including the file name in my database directly as an attribute of my product like: <img id='productImage' src="{% static 'buylist/img/images/{{product.image}}' %}"> There was still no image where I would expect one, but when I inspected the element on the page it had the correct filename image name.jpg. I don't know too much about html, but this led me to believe there was some sort of problem with my directory settings. I tried including in my … -
Why my form input of type number is not getting any value?
pleease help. I am trying to get the value of the input with id amount_0027634199476. Whenever I change the value of the field, I am not getting anything through javascript after I click on the submit button which is supposed to send an alert with the input box's value. This is my code: <div class="modal-body"> <form id="frm_entry_0027634199476" method="post"> <input type='hidden' name='csrfmiddlewaretoken' value='a9wl1mTYjT1FhTmhr41zLoy6H7ay4QPvDXQHuUSNcGcMkrUNVISM7BSvRbVp3RPf' /> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12">Montant</label> <div class="col-md-9 col-sm-9 col-xs-12"> <input type="number" id="amount_0027634199476" class="form-control"> </div> </div> <div class="form-group"> <div class="col-md-9 col-sm-9 col-xs-12"> <div class="radio"> <label> <input type="radio" checked="" value="True" id="optionsRadios1" name="deposit_0027634199476"> <strong>Depot</strong> </label> </div> <div class="radio"> <label> <input type="radio" value="False" id="optionsRadios2" name="deposit_0027634199476"> <strong>Retrait</strong> </label> </div> </div> </div> </form> </div> <div class="modal-footer"> <button type="cancel" class="btn btn-primary" data-dismiss="modal">anuller</button> <button type="submit" class="btn btn-default" onclick="submiter()" >valider</button> <script> function submiter(){ x = document.getElementById("amount_0027634199476"); alert(x.value); } </script> Am I doing something wrong? How can I right it? -
Django nested dictionary to display in templates
I have a dictionary that looks like this dict = { 'https://i.redd.it/4d87ifm2mch01.jpg': 'https://reddit.com/7yv1d8', 'https://i.redd.it/ru0bq0jpr9h01.jpg': 'https://reddit.com/7ys0l3', 'videos': {'https://gfycat.com/ifr/selfassuredinfinitehochstettersfrog'},.. } 'videos' stores values as a set so i wont have duplicate urls and it's convenient. But i faced a problem, how can I display the nested dictionary in templates? I have it like that for now {% for keys,values in data.items%} {% for i,j in keys.items %} <iframe src='{{j}}' frameborder='0' scrolling='no' allowfullscreen width='300' height='300'></iframe> <a class="thumbnail" href="{{values}}"><img src="{{keys}}" width="100px" height="66px" border="1" /><span><img src="{{keys}}" /><br />whatever.</span></a> <br /> I want the 'videos' values to be stored in the <iframe> and others as an image. -
Testing and mocking a threaded function within a view
I'm trying to unit test a function that I run threaded within a view. Whenever I try to mock it, it always goes to the original function, no the mocked function. The code I'm testing, from the view module: def restart_process(request): batch_name = request.POST.get("batch_name", "") if batch_name: try: batch = models.Batch.objects.get(num=batch_name) except models.Batch.DoesNotExist: logger.warning("Trying to restart a batch that does not exist: " + batch_name) return HttpResponse(404) else: logger.info(batch_name + " restarted") try: t = threading.Thread(target=restart_from_last_completed_state, args=(batch,)) t.daemon = True t.start() except RuntimeError: return HttpResponse(500, "Threading error") return HttpResponse(200) else: return HttpResponse(400) The test function: class ThreadTestCases(TransactionTestCase): def test_restart_process(self): client = Client() mock_restart_from_last_completed_state = mock.Mock() with mock.patch("processapp.views.restart_from_last_completed_state", mock_restart_from_last_completed_state): response = client.post('/batch/restart/', {"batch_name": "BATCH555"}) self.assertEqual(response.status_code, 200) mock_restart_from_last_completed_state.assert_called_once() The URL: url(r'^batch/restart/$', views.restart_from_last_completed_state, name="restart_batch"), I always get this error: ValueError: The view processapp.processing.process_runner.restart_from_last_completed_state didn't return an HttpResponse object. It returned None instead. I put a print command in the original function (restart_from_last_completed_state) and it always runs so the mocking does not take place. The error seems to take the function as a view although it is not. I'm not sure where the error is, the threading, testing, something else? -
Unable to import a model in another app
I am working in Django 1.8 and Python 3.5 I have 3 apps -> mainpage,login,signup and the directory is given in the picture I am trying to import mainpage/models.py in login/forms.py But when I do it it give If there is anything else you people want me to post tell me what do I do in the comments ? See Image and yes Please I have read this already but not working.Thanks in advance TRACEBACK Environment: Request Method: GET Request URL: http://localhost:8000/login Django Version: 1.8 Python Version: 3.5.4 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mainpage', 'signup', 'login', 'rest_framework', 'corsheaders') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', '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') Traceback: File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\base.py" in get_response 108. response = middleware_method(request) File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\middleware\common.py" in process_request 74. if (not urlresolvers.is_valid_path(request.path_info, urlconf) and File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in is_valid_path 647. resolve(path, urlconf) File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve 522. return get_resolver(urlconf).resolve(path) File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve 368. sub_match = pattern.resolve(new_path) File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve 240. return ResolverMatch(self.callback, args, kwargs, self.name) File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in callback 247. self._callback = get_callable(self._callback_str) File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in get_callable 106. mod = import_module(mod_name) File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py" in import_module 126. return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\views.py" in <module> 2. from .forms import UserLoginForm File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\forms.py" in … -
How Prepare the database for SALEOR
Prepare the database for SALEOR: $ python manage.py migrate This command will need to be able to create database extensions. If you get an error related to the CREATE EXTENSION command please review the notes from the user creation step. # python3 manage.py migrate Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 216, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 36, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/migrate.py", line 12, in <module> from django.db.migrations.autodetector import MigrationAutodetector File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/autodetector.py", line 11, in <module> from django.db.migrations.questioner import MigrationQuestioner File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/questioner.py", line 9, in <module> from .loader import MigrationLoader File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/loader.py", line 8, in <module> from django.db.migrations.recorder import MigrationRecorder File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/recorder.py", line 9, in <module> class MigrationRecorder: File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/recorder.py", line 22, in MigrationRecorder class Migration(models.Model): …