I have a model Menu:
class Menu(models.Model):
loja = models.ForeignKey(Loja, related_name='menus')
nome = models.CharField(max_length=30)
ordenacao = models.IntegerField(blank=True, null=True)
class Meta:
ordering = ('ordenacao',)
#prevent equally named menus within a store(loja)
unique_together...
I have two models in different apps: modelA and modelB. They have a one-to-one relationship. Is there a way django can automatically create and save ModelB when modelA is saved?
class ModelA(models.Model):
name = models.CharField(max_length=30)
class ModelB(models.Model):
thing = models.OneToOneField(ModelA, primary_key=True)...
I want to have a model with calculated fields that I can apply sorting on. For example, let's say that I have the following model:
class Foo(models.Model):
A = models.IntegerField(..)
B = models.IntegerField(..)
C = models.ForeignKey(..)
I want to have a D and an E field that are calculated by the following formulas:
D =...
Hi People.
I'm trying to solve the relational model in order to make a Django app.
I't will be something like a McDonald's crew scheduler. I mean the grid with colored pins marking who will be working at a given hour a given weekday.
I did try to Google out some example, but I didn't find anything. I need some theory/bibliography in o...
I just setup django-sphinx, and it is working beautifully. I am now able to search my model and get amazing results. The one problem is that I have to build the index by hand using the indexer command. That means every time I add new content, I have to manually hit the command line to rebuild the search index. That is just not acceptable...
I have a fixture with multiple models that I'm using for testing. It
works for the basic models, but fails to create the entities for the
models with relationships. Is this a known limitation of app-engine-patch or am I missing
something? I'm using JSON for the fixture file.
I'm creating the fixture file with 'manage.py dumpdata --fo...
I am trying to load a google web toolkit application with django, but the gwt host page does not seem to work (just a blank screen) when I invoke it with render_to_response() from my django view. I have verified that a plain hello-world html file loads fine from the gwt war directory, so it's not a path issue. Also the host page renders ...
Hello,
I have simple question model :
class Question(Polymorph):
text = models.CharField(max_length=256)
poll = models.ForeignKey(Poll)
index = models.IntegerField()
And I would like to prepopulate ( when saving ) index field with ID value. Of course before save I dont have ID value ( its created after it ), so I wonder w...
Here is a related manager I wrote:
class PortfolioItemManager(models.Manager):
use_for_related_fields = True
def extended(self):
return self.extra(select = {'current_price':'current_price', 'current_value':'current_price*quantity', 'gain':'current_price*quantity - cost'},
tables = ['pm_core_contr...
I am using YUI 3.0 io to submit form data with ajax. The form fields are created from a django view (ModelForm). The first time the form loads, I update a field and submit the form using YUI onclick which calls the io callback which runs the django view and returns the ModelForm again with the update data. This works once (saves to datab...
Here is my situation...
I am trying to dynamically generate a bunch of stuff in my settings.py file on a django site.
I am setting up several sites, (via sites framework) and I want to have some values I plug in to a function that will generate a portion of the settings file for each site.
for example:
from universal_settings import ...
Hi!
Could you please help.
I am using the django-amf-gateway application (http://bitbucket.org/wolever/django-amf-gateway).
I defined the gateway this way:
from django_amf_gateway import register_amf_service
from goserver.models import Game
class ChangeService(object):
def state(self):
game = Game.objects.get(id = 1)
...
I had a small proof of concept set up on a development server on a local machine. I'm now trying to move it over to django on a production server, which I'm using webfaction for. However, now that I'm switched over to apache from the built in django server I get the following:
ViewDoesNotExist: Could not import orgDisplay.views. Error...
I have a custom action on a model Foo all set up and ready to go, complete with a new permission I've made.
Problem is, my administrators need the can_change_foo permission to view a change list and perform that custom action (which I don't want to award).
Is there an easier way to set this up without rewriting the model list admin vie...
We'd like to create a Django Intranet application for mass market. We only need to support Windows users, and it needs to be very easy for a Windows admin (or "technical user") to deploy (baring in mind that most Windows admins/users have little experience with Python, etc).
Is Django + py2exe the answer? Do we need something extra, or ...
In my Django app, I have a mix of doctests (defined in models.py and views.py) and unit tests (defined in tests.py. I can invoke an individual unit test by doing:
manage.py test app.TestCase
However, this doesn't seem to work for the doctests. Is there some way to run a single doctest (defined in models.py or views.py)?
...
I have a rather generic model, as follows:
class Keyword(models.Model):
ancestors = models.ManyToManyField(Keyword)
name = models.CharField()
description = models.CharField()
Trouble is, I have several different types of keywords, which all have different forms of business logic. Some, for example, are never allowed to hav...
I am using Django's unit testing apparatus (manage.py test), which is throwing an error and halting when the code generates a warning. This same code when tested with the standard Python unittest module, generates warnings but continues code execution through them.
A little research shows that Python can be set to raise warnings to exc...
Hello!
I have two models that are basically this:
Book(Model):
title = models.CharField(max_length = 250)
read_by = ManyToManyField(User)
...
User(Model):
firstName = models.CharField(max_length = 250)
lastName = models.CharField(max_length = 250)
...
Now, how do I create a list of all books with a "read" b...
I have a Django app (on Google App Engine) that I wish to internationalize.
settings.py:
USE_I18N = True
LANGUAGE_CODE = 'en'
# Restrict supported languages (and JS media generation)
LANGUAGES = (
('en', 'English'),
('fr', 'French'),
)
MIDDLEWARE_CLASSES = (
'ragendja.middleware.ErrorMiddleware',
'django.contrib.sessions.midd...