django-database

Models does not create tables when synched

风流意气都作罢 提交于 2019-12-04 17:51:18
I have some django models for my extended users profile. Problem is that this code does not create tables when syncdb is used (simply nothing happens. No validation errors). Why is that happening? (Also those models give import error elsewhere) : #!/usr/bin/env python # encoding: utf-8 from django.db import models from django.contrib.auth.models import User from registration.signals import user_registered from forms import ExtendedRegistrationForm import hashlib class InheritedProfile(models.Model): first_name = models.CharField("Name", max_length=50, blank=True, null=True) last_name = models

database error no such table django

余生颓废 提交于 2019-12-04 16:23:36
I have made a new app 'api' in the django project 'cc'. I have a remote database 'launchg' which I integrated it with Django using Legacies and used python manage.py inspectdb > models.py to generate a models.py file. Next replaced the generated models.py file with the models.py file in the api app. Whenever I try to fire a query into this Database database error:no such table For Eg :- WebQuery.objects.all() , it throws an error stating database error: no such table : web_query Here is my models.py file # This is an auto-generated Django model module. # You'll have to do the following

Issues with feeding data into database when using for loop

喜你入骨 提交于 2019-12-04 15:03:52
In my template I have used for loop for some fields <div class="register_div"> <p>Title:</p> <p>{{ form.title }}</p> </div> <div class="register_div"> <p>Upload Images :</p> <p>{{ form.image }}</p> </div> {% for item in product %} <div class="register_div"> <p>{{ item.Name }} <input type="text" name="custom[{{item.id}}]"/></p> </div> {% endfor %} <div class="register_div"> <p>Price:</p> <p>{{ form.price }}</p> </div> As code shows there is one field which using for loops if that field has three records then in the form it shows three text boxes so that user can feed data to all three fields,

Django 500 Internal Server Error - ImproperlyConfigured: Error loading MySQLdb module:

馋奶兔 提交于 2019-12-04 05:18:23
问题 Im new to using MySQL in general and as a database for Django. I have followed a number of different tutorials and the documentation but keep getting a 500 Internal Server Error when i deploy to my production server. It works fine on my development machine. What am I missing? is there a setting I should change or a step i missed? Thanks The Error logs [Mon Aug 18 19:23:10 2014] [error] [client 134.226.38.233] return getattr(connections[DEFAULT_DB_ALIAS], item) [Mon Aug 18 19:23:10 2014]

Add Indexes (db_index=True)

怎甘沉沦 提交于 2019-12-03 01:17:55
问题 I'm reading a book about coding style in Django and one thing they discuss is db_index=True . Ever since I started using Django, I've never used this function because I'm not really sure what it does. So my question is, when to consider adding indexes? 回答1: This is not really django specific; more to do with databases. You add indexes on columns when you want to speed up searches on that column. Typically, only the primary key is indexed by the database. This means look ups using the primary

Exporting to SPSS files in Python Django?

北慕城南 提交于 2019-12-02 06:50:42
问题 i need to export data to SPSS file format in Python (Django), but i can't find util information in google. Is there some way to do this? Someone has tried? thanks in advance! 回答1: The savReaderWriter package can be used to read or write SPSS files (.sav, zsav), including metadata: https://pypi.python.org/pypi/savReaderWriter/3.1.2 回答2: As far as I am aware, the only API provided by IBM to interact with SPSS is designed to be used in C/C++. You will have to look up the appropriate SPSS

Django 500 Internal Server Error - ImproperlyConfigured: Error loading MySQLdb module:

旧时模样 提交于 2019-12-02 06:24:14
Im new to using MySQL in general and as a database for Django. I have followed a number of different tutorials and the documentation but keep getting a 500 Internal Server Error when i deploy to my production server. It works fine on my development machine. What am I missing? is there a setting I should change or a step i missed? Thanks The Error logs [Mon Aug 18 19:23:10 2014] [error] [client 134.226.38.233] return getattr(connections[DEFAULT_DB_ALIAS], item) [Mon Aug 18 19:23:10 2014] [error] [client 134.226.38.233] File "/var/www/bias_experiment/lib/python2.7/site-packages/django/db/utils

Exporting to SPSS files in Python Django?

邮差的信 提交于 2019-12-01 23:55:31
i need to export data to SPSS file format in Python (Django), but i can't find util information in google. Is there some way to do this? Someone has tried? thanks in advance! The savReaderWriter package can be used to read or write SPSS files (.sav, zsav), including metadata: https://pypi.python.org/pypi/savReaderWriter/3.1.2 alxbl As far as I am aware, the only API provided by IBM to interact with SPSS is designed to be used in C/C++. You will have to look up the appropriate SPSS developer's guide for your version of SPSS and download the required files from their website. That being said, I

Django - Runtime database switching

笑着哭i 提交于 2019-11-30 19:42:46
In my work we want to run a server with multiple databases. The databases switching should occur when you acces a url like http://myapp.webpage.com or http://other.webpage.com . We want to run only one server instance and at the moment of the HTTP request switch the database and return the corresponding response. We've been looking for a mantainable and 'Django-friendly' solution. In our investigation we have found possible ways to do this, but we have not enough information about. Option 1: Django middleware The django middleware runs each time the server receive a HTTP request. Making a

Django update table using data from another table

☆樱花仙子☆ 提交于 2019-11-30 06:27:17
I have 2 tables products and catagories connected by foreign key. I need to update field products.new_cost using field catagories.price_markup as following: UPDATE products p INNER JOIN categories c ON p.category_id = c.id SET p.new_cost = ROUND(p.pleer_cost * (1 + c.price_markup/100), -1) WHERE p.update = 1 In SQL it's so easy, but how to do it using Django ORM? My simplified try doesn't work Cannot resolve keyword 'category.price_markup' into field. : Product.actived.select_related('category').filter(update=1)).update(new_cost=F('pleer_cost') * F('category.price_markup')) You cannot use F,