django-1.9

Import Error : No module named django_orm

为君一笑 提交于 2019-12-22 10:28:45
问题 While importing CredentialsField from oauth2client.django_orm , I am getting: Import Error: No module named django_orm I've already installed the prerequisites: django-orm and python-oauth2 . 回答1: It looks like there's been a change on the OAuth2 library: Refactor all django-related code into oauth2client.contrib.django_util. Add DjangoORMStorage, remove FlowField. (#546) You can check this here. Perhaps you can try something like this (I don't get any import errors when running it, but I am

Why did Django 1.9 replace tuples () with lists [] in settings and URLs?

て烟熏妆下的殇ゞ 提交于 2019-12-20 11:00:48
问题 I am bit curious to know why Django 1.9 replaced tuples () with lists [] in settings, URLs and other configuration files I just upgraded to Django 1.9 and noticed these changes. What is the logic behind them? INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles' ] AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation

Django 1.9 ImportError for import_module

拈花ヽ惹草 提交于 2019-12-17 11:18:27
问题 When trying to run either runserver or shell using manage.py I get an ImportError exception. I'm using Django 1.9. ImportError: No module named 'django.utils.importlib' 回答1: django.utils.importlib is a compatibility library for when Python 2.6 was still supported. It has been obsolete since Django 1.7, which dropped support for Python 2.6, and is removed in 1.9 per the deprecation cycle. Use Python's import_module function instead: from importlib import import_module The reason you can import

How to serialize Django GeoPt for Elasticsearch

牧云@^-^@ 提交于 2019-12-14 03:05:46
问题 How to define GeoPointField() in elasticsearch django. It shows a serialization error when i am trying to save the instance. i am using library "django_elasticsearch_dsl code: from django_elasticsearch_dsl.fields import GeoPointField geolocation = GeoPointField() when i am trying to save the data user = GutitUser.objects.get(phone_number=phone_number) lat, lon = get_lat_long() user.geolocation.lat = lat user.geolocation.lon = lon user.save() it shows error: "Unable to serialize <django_google

ModuleNotFoundError: No module named 'django.urls'

随声附和 提交于 2019-12-13 17:21:38
问题 Whenever I try to run "python manage.py runserver" in Powershell as admin, I get an ModuleNotFoundError: No module named 'django.urls' . Can somebody help me please?! I'm using django 1.9 and python 3.6 IN POWERSHELL File "C:\Users\MAHE\PycharmProjects\website_new\website_new\urls.py", line 3, from django.urls import path ModuleNotFoundError: No module named 'django.urls' IN URLS.PY: from django.contrib import admin from django.urls import path urlpatterns = [ django.urls.path('admin/', admin

django one app one model multiple databases

喜夏-厌秋 提交于 2019-12-12 03:02:16
问题 I am new to django webapp development and i am stuck with a problem. I have created 1 app with 1 model to insert data to the database using 1 form. I am going to use multiple databases for this. Each database will have 1 table(for now) with same structure. Now my problem is: How can I use just 1 model, 1 view and 1 form for multiple databases and their respective tables. Databases and tables should be switched on calling their respective urls. e.g. http://www.example.com/x/abc/ will access

DRF - Base Viewset for query param validation

寵の児 提交于 2019-12-12 02:27:44
问题 I am using Django 1.9 and Django Rest Framework 3.3 I'm creating three new endpoints that are similar but still different enough that I want them to be their own viewsets to avoid messy code. They are not backed by a model so I am extending ViewSet directly. One similarity between all three endpoints is they require the same two query parameters. So I find I am doing this: class MyFirstViewset(viewsets.ViewSet): def list(self, request): some_param = request.query_params.get('someparam') if

Weird ephemeral error for ManyToMany fields during Django migrations

青春壹個敷衍的年華 提交于 2019-12-11 17:14:39
问题 There's this weird error that my company has been facing since the last few months. We have a ton of model s in our code and a lot of them have ManyToMany fields in them. For ex - class TypeMapping(models.Model): name = models.TextField(null=True, blank=True) from_config_type = models.ManyToManyField(Type, blank=True, related_name="from_config_type") to_config_type = models.ManyToManyField(Type, blank=True, related_name="to_config_type") Sometimes, and only sometimes, after a deployment, we

How do I check if a User is using a mobile device in Django 1.9?

﹥>﹥吖頭↗ 提交于 2019-12-11 11:07:52
问题 I'm using Django 1.9 with Python 2.7 and I'm trying to get my app to recognize if the user is browsing with a mobile device. I've tried django_mobile but it seems outdated for django 1.9 because there aren't even template_loaders to install the app, am I wrong about this? 回答1: or you can use django-user_agents app. really good one. you also get the context in your template - among others important for rendering some ads depending on device in view request.user_agent.is_mobile or in template {

Django1.9: 'function' object has no attribute '_meta'

…衆ロ難τιáo~ 提交于 2019-12-11 06:08:30
问题 Django Gives an error message forms.py: from django import forms from django.contrib.auth import authenticate, get_user_model, login, logout from django.contrib.auth.forms import UserCreationForm User = get_user_model class UserLoginForm(forms.Form): username = forms.CharField() password = forms.CharField(widget=forms.PasswordInput) def clean(self, *args, **kwargs): username = self.cleaned_data.get("username") password = self.cleaned_data.get("password") user = authenticate(username=username,