I have a model, which has several "automatic" fields, like this:
class Message(Model):
subject = CharField(max_length = 200)
message = TextField()
created = DateTimeField()
last_status_change = DateTimeField()
status = CharField(max_length = 10)
In my database (Postgres) I set up default values for created, last_st...
Hey everyone.
I am trying to import a small CSV file into my django program. I am using SQL, and here is what I have so far. The CSV file itself has Column1 which is named Customer and I am trying to take that information and assign it to the model field name 'client_name'. Problem I get when I run this query is that I keep getting t...
Hi,
I have been looking for an answer for this problem.
I have a schema with these models
Users.
Questions.
Answers given by users to a question.
You understand there are 2 foreign keys in an answer:
One foreign key to Question
Another one to User
I want to get a list of rows containing the commons questions answered by 2 users,...
Hey guys.
I have a system that relies on other models but want to make it a little more open-ended as my users demand a bit more sometimes.
currently for arguments sake I have 2 authors in an Author model.
john, james
When a user adds a book, and the Author is not available, how do I add a other field in the form, that if selected, ...
Hi folks,
I'm using Django 1.3beta and django-mongodb-engine for database backend.
Problem is when I save an object with a pk set I get this error:
/usr/local/lib/python2.6/dist-packages/django/db/models/fields/__init__.pyc in get_prep_lookup(self, lookup_type, value)
290 return value
291 elif lookup_type i...
I have a view that displays object information when the correct URL is provided however I would like to create a similar view that returns url information from the record that is located next.
So in essence take the info from my first view, list/order it in some way preferably by date and return the records located next and previous in ...
Hi, I want to design a Task model that can be associated to Project Models, another X model, and other Task models. The obvious choice is a foreign key, but I want any particular instance of that Task model to only be associated to only one of those model types, that is, if a Task model has a relationship with a Project model, it cannot ...
Hi All,
I have to implement an application in django which will track all the changes in the database with the previous values,current value,action,date,time, user(who performed the changes) etc.
Is there any application/module available in python or django which can perform these actions with may be after some changes. I have seen "f...
Django: If I added new tables to database, how can I query them?
Do I need to create the relevant models first? Or django creates it by itself?
More specifically, I installed another django app, it created several database tables in database, and now I want to get some specific data from them? What are the correct approaches? Thank you...
I'm creating a turn and text-based strategy game in Django on Google App Engine with app-engine-patch. The simplified concept is that each player build can several different units and buildings to improve their base and fight other players for points.
My question involves the designing of the Django models, it seems to me that the buil...
The following code is being used by the admin to save a Loan object
import uuid
from django.db import models
from django.contrib.auth.models import User
from apps.partners.models import Agent
# Create your models here.
class Loan(models.Model):
""" This is our local info about the loan from the LOS """
guid = models.CharField(...
Example
class Base():
pass
class A(Base)
parent=models.Foreignkey("self", limit_choices_to=(all members of the B class)
class B(Base)
parent=models.Foreignkey("self", limit_choices_to=(all members of the A class)
What would be the query syntax for limit_choices_to, to get only the
objects of a certain class?)
...
I just migrated my django application from sqlite3 to mysql 5.1.41. I have a charfield in a model defined like this:
class HostData(models.Model):
Host = models.CharField(max_length=50, null=True)
HostStatus = models.CharField(max_length=200, null=True)
Alarm = models.BooleanField()
Everything works the same except HostStatus, w...
I have tried multiple aproaches, but as I cannot use self in the class body, self.__class__.__name__ is not available. Would I need to override the save method to do this? Thanks for your help.
...
I'm learning Django and trying to get the hang of querying foreign keys across a bridging table. Apologies if this is a duplicate, I haven't been able to find the answer by searching. I've got models defined as follows
class Place(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=100)
c...