Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django crispy form render model form twice?
I'm trying to use crispy form for model forms. It's working fine first. Then I want to split the fields into two columns, so I have to use the layout in the helper. But django complained ppp1 and ppp2 are rendered twice. I can't remove the fields since it causes a django error. Does anyone know how to resolve this issue? thanks in advance class PPPAddForm(forms.ModelForm): class Meta: model = PPP fields = ['ppp1', 'ppp2' ] def __init__(self, *args, **kwargs): super(PPPAddForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-sm-2' self.helper.field_class = 'col-sm-4' self.helper.layout.append( FormActions( Div( Div('ppp1', css_class="col-sm-6"), Div('ppp2', css_class="col-sm-6"), css_class='row' ), Submit('save_changes', 'Save changes', css_class="btn-primary"), Submit('cancel', 'Cancel'), ) ) -
[Django][Custom database] 'ImportError: cannot import name backend' error when I try to load any page - using django-salesforce
I'm using django-salesforce (https://github.com/django-salesforce/django-salesforce) and followed the docs to add it to this skeleton app (https://github.com/GoogleCloudPlatform/appengine-django-skeleton). I have a working solution that GETs and POSTS to my Salesforce data when I run my application locally via a python script. But now I'm trying to deploy my application to GAE and run the webserver but whenever I load a webpage I get an exception thrown: Traceback (most recent call last): File "/Applications/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 267, in Handle result = handler(dict(self._environ), self._StartResponse) File "/Users/chrisa/standard_django_hello_world/customer_data_salesforce/lib/django/core/handlers/wsgi.py", line 165, in __call__ signals.request_started.send(sender=self.__class__, environ=environ) File "/Users/chrisa/standard_django_hello_world/customer_data_salesforce/lib/django/dispatch/dispatcher.py", line 192, in send response = receiver(signal=self, sender=sender, **named) File "/Users/chrisa/standard_django_hello_world/customer_data_salesforce/lib/django/db/__init__.py", line 55, in reset_queries for conn in connections.all(): File "/Users/chrisa/standard_django_hello_world/customer_data_salesforce/lib/django/db/utils.py", line 227, in all return [self[alias] for alias in self] File "/Users/chrisa/standard_django_hello_world/customer_data_salesforce/lib/django/db/utils.py", line 212, in __getitem__ backend = load_backend(db['ENGINE']) File "/Users/chrisa/standard_django_hello_world/customer_data_salesforce/lib/django/db/utils.py", line 135, in load_backend raise ImproperlyConfigured(error_msg) ImproperlyConfigured: 'salesforce.backend' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3' Error was: No module named backend.base INFO 2016-10-21 20:58:32,559 module.py:788] default: "GET / HTTP/1.1" 500 - INFO 2016-10-21 20:58:33,154 module.py:402] [default] Detected file changes: /Users/chrisa/standard_django_hello_world/customer_data_salesforce/mysite My settings.py looks like: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'HOST': <redacted for github> 'NAME': 'db', 'USER': 'pythonapp', … -
Django PostgreSQL JSONField db_index error
My model: from django.db import models from django.contrib.postgres.fields import JSONField class MyModel(models.Model): data = JSONField(blank=True, null=True) I have created some objects and filled "data" field with some JSONs Then I tried to create index for "data" field class MyModel(models.Model): data = JSONField(blank=True, null=True, db_index=True) Make migrations python manage.py makemigrations Migrate python manage.py migrate Long traceback, and last line is: django.db.utils.OperationalError: index row requires 8336 bytes, maximum size is 8191 How can I fix it? -
Perplexing Django sqlite3 "unable to open database file" error
Been banging my head against this for a couple hours now. So here's the story, I'm trying to spin up a django application on a client's Windows machine. I've installed it successfully there before, and have made no changes to the database tables, models, or anything remotely touching the settings since the last successful installation. So I copy over the files, then run manage.py migrate to generate the necessary tables. However, I get this error: Error Log Operations to perform: Apply all migrations: admin, contenttypes, auth, sessions Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial...Operations to perform: Apply all migrations: admin, contenttypes, auth, sessions Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial...Traceback (most recent call last): File "C:\Softrend\F3KWebApi\manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line utility.execute() File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 399, in execute output = self.handle(*args, **options) File "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 200, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", line 92, in migrate self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", line 121, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", line 198, in apply_migration state = migration.apply(state, schema_editor) File "C:\Python27\lib\site-packages\django\db\migrations\migration.py", line … -
Django app has multiple database and multiple user
I have written one Django cloud based app. This app will have multiple user and for them multiple database, so that their data should be separate and they can save only to same database. 1) How can we implement it 2) How to automatically one user from login page to assign the database to write on it. -
How can I make django to write static files list to database when using collectstatic
I am storing all the static files in AWS S3 Bucket and I am using Docker containers to run my application. This way, whenever I want to deploy the changes, I create a new container using a new image. I am running ./manage.py collectstatic on every deployment because sometimes I add libraries to the project that have static files; and it takes forever to reupload them to S3 on every deployment. Is there a way I can keep a list of static files uploaded to S3 in my database, so that collectstatic only uploads to the added files. -
Problems deploying GeoDjango application on Heroku
I'm having troubles to deploy my GeoDjango application on heroku (using Free Dyno but I'm able to change if necessary). When I execute push heroku master --force I got the following error: Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3' Error was: cannot import name 'GDALRaster' I already installed postgis: $ heroku pg:psql create extension postgis; Configured buildpacks: heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git Created .buildpacks file at my project with this links: https://github.com/cyberdelia/heroku-geo-buildpack.git#1.1 https://github.com/heroku/heroku-buildpack-python.git#v29 Updated Procfile: web: python manage.py collectstatic --noinput; gunicorn projectname.wsgi My settings.py it's configured: INSTALLED_APPS = [ .... 'django.contrib.gis', ] default_dburl = 'sqlite:///' + os.path.join(BASE_DIR, 'db.sqlite3') DATABASES = { 'default': config('DATABASE_URL', default=default_dburl, cast=dburl), } DATABASES['default']['ENGINE'] = config('DB_ENGINE') My DB_ENGINE is at .env file: DB_ENGINE=django.contrib.gis.db.backends.postgis References I already read: Installing postgis Buildpacks Buildpacks 2 Configuring GeoDjango I can't figure out solutions, Thanks in advance for any help. -
Django: Static Files not displayed on deployment server
I can not get my site to load the static files correctly. settings.py files in regards static files is as follows: # Static files STATIC_URL = '/static/' STATIC_ROOT = '/var/www/str8red.com/static/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) When I run the following command: python manage.py collectstatic I get the following outcome: 1858 static files copied to '/var/www/str8red.com/static' When I check the directory everything seems to have worked correctly. I then go and checkout my site online at "https://str8red.com/" and none of the css or images are working. An example error I am seeing in chrome developer mode is as follows: GET https://str8red.com/static/str8RED.png 404 (Not Found) The file is being grabbed using the following code: {% load staticfiles %} <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="{% url 'index' %}"> <img src="{% static 'str8RED.png' %}" width="97" height="22" alt="str8RED.com" /> </a> Any help greatly appreciated, many thanks, Alan. -
Django all-auth get facebook profile pic
I have auth setup with all-auth. Is it possible using all-auth make a query to fb to get a link to profile pic ? If not - what is proper way to do that ? -
Gmail API credentials on Django
I have an email script using gmail API that works fine locally.But when I implemented the same on django, I keep getting raise IOError(_IS_DIR_MESSAGE.format(filename)) IOError: /home/ubuntu/.credentials: Is a directory Here's the credentials function : def get_credentials(): """Gets valid user credentials from storage. If nothing has been stored, or if the stored credentials are invalid, the OAuth2 flow is completed to obtain the new credentials. Returns: Credentials, the obtained credential. """ home_dir = os.path.expanduser('~') credential_dir = os.path.join(home_dir, '.credentials') credential_path = os.path.join(credential_dir, 'gmail-python.json') store = oauth2client.file.Storage(credential_path) credentials = store.get() if not credentials or credentials.invalid: flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES) flow.user_agent = APPLICATION_NAME if flags: credentials = tools.run_flow(flow, store, flags) else: # Needed only for compatibility with Python 2.6 credentials = tools.run(flow, store) print('Storing credentials to ' + credential_path) return credentials Although this works fine locally, Django keeps throwing File "/home/ubuntu/gmailbot/emailbot/gmailbot.py", line 109, in main credentials = get_credentials() File "/home/ubuntu/gmailbot/emailbot/gmailbot.py", line 92, in get_credentials credentials = store.get() and raise IOError(_IS_DIR_MESSAGE.format(filename)) IOError: /home/ubuntu/.credentials: Is a directory -
Django set slug in view
can anyone tell me how to set a slug in a view? I pretend to use name as slug, def editar_cliente(request, pk): detail = database.objects.get(pk=pk) name = detail.name company = detail.company pk = detalle.pk return render(request, 'edit_client.html'company': company, 'pk':pk}) -
Redirecting to an external website from django view
Is there a way to redirect to another website from inside a Django view? I tried return redirect("www.google.com"), but that doesn't work. -
Adding a Django site breaks my virtual hosts on CentOS 7
I have a CentOS 7 server with about 20 domains all managed automatically with a vhosts file in /etc/httpd/conf.d. I am trying to learn Django and wanted to set up a single domain using it, so I added a specific virtualhost to the .conf file. The result is that the Django domain works fine but all the other sites are broken (try to use Django but cause errors). The Django domain has two folders: djangodomain.com for static files and djangodomain.app for the Python files. How can I integrate a single Django domain into my existing many-domain virtual host setup? Existing vhosts.conf: <VirtualHost *:80> serveradmin username@domain.com serveradmin username@domain.com usecanonicalname off # www.site.com » site.com rewriteengine on rewritecond %{HTTP_HOST} ^www\.(.*)$ [nc] rewriterule ^(.*)$ http://%1 [r=301,l] # file locations virtualdocumentroot "/home/username/%0" <directory "/home/username/*"> allowoverride all require all granted options indexes followsymlinks options +execcgi options +includes </directory> </VirtualHost> What I added that broke all but the Django site: <VirtualHost djangodomain.com:80> ServerName djangodomain.com ServerAlias www.djangodomain.com ServerAdmin user@domain.com DocumentRoot /home/username/djangodomain.com WSGIScriptAlias / /home/username/djangodomain.app/django.wsgi <Directory /home/username/djangodomain.app> Order allow,deny Allow from all </Directory> Alias /robots.txt /home/username/djangodomain.com/robots.txt Alias /favicon.ico /home/username/djangodomain.com/favicon.ico Alias /images /home/username/djangodomain.com/images Alias /static /home/username/djangodomain.com/static ErrorLog /home/username/djangodomain.logs/error.log CustomLog /home/username/djangodomain.logs/access.log combined </VirtualHost> -
Django validation when creating new instances of models
I am new to Django and am using the Django Rest Framework tutorial to create web API's. I have the following models and I have views which use the createAPIView to create new instances of each of these models. class ValidationClass (models.Model): id = models.IntegerField(primary_key=True, null=False) name = models.CharField(max_length=128, unique=True) parameters = models.TextField() def __str__(self): return '{} - {} - {}'.format(self.id, self.name, self.parameters) db = 'qa_suite' class Test(models.Model): id = models.IntegerField(primary_key=True, null=False) name = models.CharField(max_length=128, unique=True) test_group = models.ForeignKey(TestGroup) description = models.TextField() query_text = models.TextField() failure_condition = models.CharField(max_length=20, choices=( ('Error', 'Error'), ('Warn', 'Warn') ), default = 'Error') status = models.CharField(max_length=20, choices=( ('Enabled', 'Enabled'), ('Disabled', 'Disabled') ), default = 'Enabled') created = models.DateTimeField('Creation Date', auto_now_add=True, blank=True) updated = models.DateTimeField('Date last updated', auto_now_add=True, blank=True) def __str__(self): return '{} - {}'.format(self.id, self.name) db = 'qa_suite' class TestValidation(models.Model): test = models.ForeignKey(Test) validation_class = models.ForeignKey(ValidationClass) input_parameters = models.TextField() def __str__(self): return '{} - {} - {}'.format(self.test, self.validation_class, self.input_parameters) class Meta: unique_together = (('test', 'validation_class'),) db = 'qa_suite' What I would like to do, is make sure that every time a new Test object is created, it is linked to at least one ValidationClass object. The Test object has a one to many relationship with the … -
Django User model and multiple model one to one relationship issue
I have two model Doctor and Patient having many to many relationship. Both Doctor and Patient is users of my system, so i want to relate it with User module using one-to-one relationship. Doctor model have another relation with Hospital by many-to-many. Below is my code: from django.contrib.auth.models import User from django.db import models from datetime import date class Doctor(models.Model): photo = models.ImageField(upload_to='/uploads/photos', default='/uploads/photos/doctor_default_photo.gif') degree = models.CharField(max_length=200) speciality = models.CharField(max_length=200) educational_institute = models.CharField(max_length=200) experience = models.IntegerField(null=True) user = models.OneToOneField(User) class Patient(models.Model): user = models.OneToOneField(User) disease = models.CharField(max_length=100, null=True) dob = models.DateField('date of birth') doctors = models.ManyToManyField(Doctor, through='Appointment') def patient_age(self): today = date.today() year, month, day = map(int, self.dob.split('-')) return today.year - year - ((today.month, today.day) < (month, day)) class Appointment(models.Model): doctor = models.ForeignKey(Doctor, on_delete=models.CASCADE) patient = models.ForeignKey(Patient, on_delete=models.CASCADE) date = models.DateField() time = models.TimeField() But, when I run the migrate command I get following error. psycopg2.IntegrityError: column "user_id" contains null values -
Pillow - cannot import name '_imaging'
I've just create a new Django app and when I try upload a picture I get the following error message. I've tried to delete any reference of PIL in the site-packages folder and install it again but still the same error message. Any idea? Field logo = models.ImageField(upload_to=logo_name, null=True, blank=True) Error Message ImportError at /secret/teams/team/add/ cannot import name '_imaging' Request Method: POST Request URL: http://echanj.com/secret/teams/team/add/ Django Version: 1.10.2 Exception Type: ImportError Exception Value: cannot import name '_imaging' Exception Location: /home/ymorin007/.virtualenvs/echanj/lib/python3.4/site-packages/PIL/Image.py in <module>, line 67 Python Executable: /usr/local/bin/python3 Python Version: 3.5.2 Python Path: ['/home/ymorin007/webapps/echanj_com/lib/python3.5/Django-1.10.2-py3.5.egg', '/home/ymorin007/webapps/echanj_com', '/home/ymorin007/webapps/echanj_com/src', '/home/ymorin007/webapps/echanj_com/lib/python3.5', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/site-packages', '/home/ymorin007/.virtualenvs/echanj/lib/python3.4/site-packages'] Server time: Fri, 21 Oct 2016 14:03:23 -0400 -
Django not loading 'extends' template in production
I'm pretty new to Python/Django, but I'm trying to publish an app in AWS Elastic Beanstalk and it's not finding some of the templates. When I request http://www.example.com/path, it throws an error: TemplateDoesNotExist at /path And it says: Error during template rendering In template /opt/python/bundle/5/app/src/app_name/templates/app_name/tmpl.djhtml, error at line 1 1 {% extends 'app_name/base.djhtml ' %} 2 ... So, it loads the main template, but it doesn't load the one specified with extends. What's worse, it says: Django tried loading these templates, in this order: Using engine django: ... django.template.loaders.app_directories.Loader: /opt/python/bundle/5/app/src/app_name/templates/app_name/base.djhtml (Source does not exist) If I connect via SSH to the server, the file DOES exist! It also works in my machine in Windows. If I do an ls -hal in that directory, the permissions are the same for both files: -rw-r--r-- 1 wsgi root 512 Oct 21 17:18 tmpl.djhtml -rw-r--r-- 1 wsgi root 3.0K Oct 21 17:18 base.djhtml The TEMPLATES settings are as follows: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates').replace('\\','/'),], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] Any ideas? Thanks. -
Django cas client TypeError
I'm using django_cas_client 1.2.0, and I'm getting the following error. Also, I'm using Django 1.10, and it's my first time using it. urls.py: urlpatterns += [ url(r'^accounts/login/$', 'cas.views.login', name='login'), url(r'^accounts/logout/$', 'cas.views.logout', name='logout'), ] Full error: Unhandled exception in thread started by <function wrapper at 0x7fbeff26eb90> Traceback (most recent call last): File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run self.check(display_num_errors=True) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/core/management/base.py", line 385, in check include_deployment_checks=include_deployment_checks, File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/core/management/base.py", line 372, in _run_checks return checks.run_checks(**kwargs) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/core/checks/urls.py", line 14, in check_url_config return check_resolver(resolver) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/core/checks/urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/urls/resolvers.py", line 310, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/urls/resolvers.py", line 303, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/gs4sandh/RPWR/RPWR/urls.py", line 36, in <module> url(r'^accounts/login/$', 'django_cas.views.login', name='login'), File "/home/gs4sandh/.local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 85, in url raise TypeError('view must be a callable or a list/tuple in the case of include().') TypeError: view must be a callable or a list/tuple in the case of include(). -
Django, href and string
Abit new to Django, and this is probably a silly question. javascript variable: <script> bar = 'foo' </script> if I have a href like this: <a style="color:black;" href="{% url 'manager:file' %}">Click</a> which directs to url(r'^getfile/$', views.dd, name='file'), and def dd(request, str): print(str) <---- print 'foo' How can I with the href, get the string in the variable bar to the view function? -
Django HTML 'for loop' not displaying any of the objects in a set
so I am having trouble with my for loop which is meant to display all the tasks allocated to a user. There are four tasks allocated to them, as you can see on this imgur link . However it does not show them on the site. Here is my detail.html file: <h1>{{user.fullName}}</h1> <h4>Username: {{user.userName}}</h4> <ul> {% for i in userName.i_set.all %} <li> {{ i.taskName }} </li> {% endfor %} </ul> Here is my models.py: from django.db import models class User(models.Model): userName = models.CharField(max_length=30) password = models.CharField(max_length=100) fullName = models.CharField(max_length=50) def _str_(self): return self.fullName class Task(models.Model): userName = models.ForeignKey(User, on_delete=models.CASCADE) taskName = models.CharField(max_length=30) scores = models.CharField(max_length=100) # score should default be set to x/10 until changed def _str_(self): return str(self.userName) + ' - ' + self.taskName I know its a pain to help someone you don't know but I'd really appreciate it as ive been working on this problem for an hour and managed nothing and I'm really eager to learn what the problem is... thanks so much and have a nice day! -
Plotting pie chart using Django Cahrtit
I am trying to plot pie chart using Django chartit. Below is my code. ds = DataPool( series=[ { 'options': { 'source': racktestresult.objects.values('Date').annotate( Pass=Sum('PassNumbers'), Fail=Sum('FailNumbers'))}, 'terms': [ 'Date', 'Pass', 'Fail' ] } ] ) cht3 = Chart( datasource=ds, series_options=[ { 'options': { 'type': 'pie', 'stacking': False, 'options3d': {'enabled': True, 'alpha': 45, 'beta': 0} }, 'terms': {'Date': ['Fail']} } ], chart_options={ 'title': {'text': 'Pass/Fail - Pie Chart'} } ) What I am trying to get is just PassNumbers and FailNumbers from racktestresult model like below. How can I achieve that? -
django and jQuery autocomplete not working
I have a form which has input as name. It search the lastname and firstname field in a database. I need to autocomplete when users type the name. I was suggested to use jQuery following this link django jquery But it's not working. I tried all the suggestion in the comments, nothings works. My models class Pitable(models.Model): pid = models.TextField(db_column='PID', primary_key=True) # Field name made lowercase. lname = models.TextField(blank=True, null=True) fname = models.TextField(blank=True, null=True) locs = models.TextField(blank=True, null=True) doclist = models.TextField(db_column='PMIDlist', blank=True, null=True) # Field name made lowercase. class Meta: managed = False db_table = 'PItable' My views: import json def get_people(request): if request.is_ajax(): q = request.GET.get('term', '') persons = Pitable.objects.filter(lname__icontains = q )[:20] results = [] for person in persons: person_json = {} person_json['id'] = person.pid person_json['label'] = person.lname person_json['value'] = person.lname results.append(person_json) data = json.dumps(results) #data = json.dumps(list(Pitable.objects.filter(lname__icontains=q).values('lname'))) else: data = 'fail' mimetype = 'application/json' return HttpResponse(data, mimetype) urls: url(r'^api/get_people/', views.get_people, name='get_people'), html: <link rel="stylesheet" href="http://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css" type="text/css" media="all" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"> </script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script> <script> $(function() { $("#names").autocomplete({ source: "/api/get_people/", minLength: 2, }); }); </script> ....... <div class="ui-widget"> <label for="names">Drugs: </label> <input id="names"> </div> The runserver side says Not Found: /api/get_people/ [21/Oct/2016 16:36:05] "GET /api/get_people/?term=ra HTTP/1.1" … -
x-editable not working with bootstrap 3 in django
I'm trying to integrate x-editable library in my web application so that I can create editable elements on my page I have followed the steps in the official link of X-editable (Just the frontEnd part) This is my code in my template : {% block extra_stylesheets %} <link href="{% static 'data_management/plugins/DataTables/media/css/dataTables.bootstrap.min.css' %}" rel="stylesheet"/> <link href="{% static 'data_management/plugins/DataTables/extensions/Responsive/css/responsive.bootstrap.min.css' %}" rel="stylesheet"/> <link href="{% static 'data_management/plugins/bootstrap-editable/css/bootstrap-editable.css' %}" rel="stylesheet"> {% endblock %} {% block extra_head_javascript %} <script src="{% static 'data_management/plugins/bootstrap/js/bootstrap.min.js' %}"></script> <script src="{% static 'data_management/plugins/bootstrap-editable/js/bootstrap-editable.min.js' %}"></script> {% endblock%} {% block content %} <table class="table table-stripped"> <tr> <th class="text-center">Visit Identifier</th> <th class="text-center">Visit Date<br/> <small style="font-weight: normal;">(Click to change the date) </small> </th> </tr> {% for course in course.books_set.all %} <tr> <td class="text-center">{{ course.name }}</td> <td class="text-center"><a href="#" id="pub_date" data-type="combodate" data-value="1984-05-15" data-format="YYYY-MM-DD" data-viewformat="DD/MM/YYYY" data-template="D / MMM / YYYY" data-pk="1" data-title="Select published Date " class="editable editable-click editable-open" data-original-title="" title="" style="background-color: rgba(0, 0, 0, 0);">12/12/2012</a> </td> </tr> {% endfor %} </table> {% endblock %} and I have integrated this script in the footer of the template : <script> $(document).ready(function() { $('#visit_date').editable(); }); </script> But I don't know why this is not working ? Any help is really appreciated -
Remote python function call with django webservice
I am working on a django/python project. i want to create an api (webservices). What i want is to call a remote function from a python client. I was used to work with WSDL and WCF in ASP.Net. Is there something like this in django/python ? I started to work with djangorestframework but i do not think this is the right way. This framework allows me to put, read, insert or update objects in a database. I think REST is only dedicated to those operations. What i want is to call a remote function, without storing data on the server (this is just calculation). Thanks -
Django-Allauth, Multiple login redirect url
I have a question, how can I add more than one LOGIN_REDIRECT_URL in settings or in views for my differents users. For example, I have: Administrators, Human Resources, Teachers, students... etc and for each I need redirect to a different url, panel admin for Admin etc. I need add groups? or not? Thanks for your help!