What I mean is I have:
class Client(models.Model):
some_field = models.CharField()
class Ticket(models.Model):
client = models.ForeignKey(Client)
Tickets are FOREVER in my system, but I want users to be able to delete clients they don't want anymore. Currently it'll delete all the tickets created by the Client.
Is this a ba...
my example (I know it's not technically correct, it's just an example):
class ipAddy(models.Model):
network=models.ForeignKey(network)
ipAddy=models.IPAddressField(foo)
class device(models.Model):
hostname=models.CharField(foo)
foo=models.CharField(bar)
bar=models.CharField(foo)
class Meta:
abstract = T...
Hello djangoists.
How to I make the following possible?
models.py
class Article(models.Model):
#...
regions = models.ManyToManyField(Region)
elsewhere...
regions = Region.objects.all()
articles = Article.objects.filter(regions=regions)
Currently, the 'articles' retrieved are only from a match with the first region in the ...
I want to make sure I am testing Models/Objects in isolation and not as one huge system.
If I have an Order object and it has Foreign Keys to Customers, Payments, OrderItems, etc. and I want to test Order functionality, I need to create fixtures for all of that related data, or create it in code. I think what I really need to be doing i...
I have a model that has multiple text properties - title, short and long description etc. I want to have multilanguage site so I need a way to easy by able to add new languages and translations for this field for every item. What is the best way to achieve this?
...
Can i get model field type from a model queryset in Django?
For example:
a is b model's queryset and the b model has following fields:
f:charfield
g:foreignkey
h:manytomany
Is there any way to get field g's type from queryset a?
thx.
...
I have a model with 6 fields, but when I access them using the author field and print the result, it only displays 4 of them, field5 is not shown. The admin shows all fields. My view, model and modelform are below.
if request.POST:
c1 = Datastore.objects.get(author = request.user)
return HttpResponse(c1)
class Datastore(models...
How to use and clause in Django
For ex:
select Date(timestamp) from userlog where (Date(timestamp) >= "2008-01-02" and Date(timestamp) <= "2009-01-02") and ipaddress != "192.168.2.211";
Django query:
userlog.objects.filter(timestamp__range=(startdate,enddate),ipaddress !="192.168.2.211")
In the above there is an error ...
I'm finding it difficult to denormalise a field in a django model. I have:
class AnswerSet(models.Model):
title = models.CharField(max_length=255)
num_answers = models.PositiveIntegerField(editable=False, default=0)
answers = models.ManyToManyField(Answer, through='AnswerSetAnswer')
...
class AnswerSetAnswer(models.Mode...
I am exploring Django with MySQL & have a few things that I wanted to discuss -
How can I add an index (on some field)? Can I do it through the Django Model Layer?
If I want to migrate some old data into these new DB tables/models, will I have to write some script myself or does Django provide schema to schema mapping tools?
If I need...
I'm trying to create a model where I can store usernames and passwords for other applications. How can I set a password field in Django so that it is not in plain text in admin? Thanks in advance.
...
Django's ORM (version 1.2.3) does not preserve identity when following foreign keys back and forth. This is best explained with an example:
class Parent(models.Model):
pass
class Child(models.Model):
parent = models.ForeignKey(Parent)
parent = Parents.objects.get(id=1)
for child in parent.child_set.all():
print id(child.pa...
I need to create an app that fetches the choices for some of the fields from a web service. Those fields are things like Country (single value), State (single value), Interests (Ecology, Biology, Chemistry, etc.) (multiple values), etc.
The web service returns for Country looks like:
{
'USA':'United States of America',
'GER':'G...
I am trying to make a change at the auth.models.py file to force the password hashing function (get_hexdigest()) to not use the salt when passing the sha1. So the change would be:
auth.models.py line 33
before:
return sha_constructor(salt+raw_password)
after:
return sha_constructor(raw_password)
However, when I make the chang...
In my django app, I would like to be able to add customized help text to the admin change form for some of my models. Note I'm not talking about the field specific help_text attribute that I can set on individual fields. For example, at the top of the change form for My_Model in My_App I'd like to be able to add some HTML that says "Fo...
Hi guys, i have a "rare" behavior here, i this model:
models.py
class Area(models.Model):
area = models.CharField(max_length=150,unique=True)
slug = models.SlugField(max_length=200)
fecha = models.DateTimeField(default=datetime.date.today,editable=False)
activa = models.BooleanField(default=True)
class Empresa(models.M...
In Django, I have the following models:
class Pink(models.Model):
...
class White(models.Model):
...
pinks = models.ManyToManyField(Pink)
...
At some point, I needed to define an ordering of Pinks inside a White
(in order to have White1.pinks: P1, P2, P3 instead of a random White1.pinks: P2, P3, P1),
so I've created ...
Is there a form(or any other solution) that allows me to quickly build forms that display lists of models(with filtering, ordering etc) like the django admin site does?
...
Are the following two calls resolved to the equivalent SQL query in Django?
Chaining multiple calls
Model.objects \
.filter(arg1=foo) \
.filter(arg2=bar) \
...
Wrapping all the args together:
Model.objects \
.filter(arg1=foo, arg2=bar)
I'd like code to be readable (there are MANY more filter calls than I've shown), but only if the...
Hello All,
I am about to start a django project, where I need a base deployment, lets say just for admins initially. Later admins can add instances of my main public site.
Now, one instance will, obviously be separated by dynamic sub-domains. I need to capture sub-domains from requests, and compute accordingly. It has its own base temp...