In a system that accepts orders which have payments which have gateway transactions should the objects be like this:
class Order(object):
... Inside init ...
self.total_in_dollars = <Dollar Amount>
self.is_paid = <Boolean Value>
class Payment(object):
... Inside init ...
self.order = order_instan...
heya,
I've previously asked questions for this project, regarding the Django Admin, Inlines, Generics, etc. Thanks again to the people who contributed answers to those. For background, those questions are here:
http://stackoverflow.com/questions/1918637/django-designing-model-relationships-admin-interface-and-inline
http://stackoverfl...
how does it write.
code example please.
...
Ok, so I posted a question recently regarding an error when adding a ManyToManyField
The Models are the ones below
class MagicType(models.Model):
name = models.CharField(max_length=155)
parent = models.ForeignKey('self', null=True, blank=True)
class Spell(models.Model):
name = models.CharField(max_length=250, db_index=...
I would like to dynamically create thumbnails based on parameters in the URL. For example, http://mysite.com/images/1234/120x45.jpg would create a 120x45 thumbnail for image id 1234.
The obvious solution to this is to have a django view which does the following:
Look for a previously cached version of the image at this size.
Create a ...
Thank you for registering an account at example.com.
To activate your registration, please visit the following page:
http://example.com/activate/d5544f645c80f8a6c9af934c03a2ee2d7902dc1f/
This page will expire in 7 days.
example.com?????
i click the url,but not active my account.
why????
...
As a long time PHP developer, I'm used to the idea of setting the error level for my application to warn me when I am using an uninitialized variable. I was wondering if a similar feature exists in Django, where I can detect at run-time that I am using a variable in my template that was not explicitly passed to the template via the view...
I want use a model to save the system setting for a django app, So I want to limit the model can only have one record, how to do the limit?
...
I am using the following code and geting some indentation problem
from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
I am geting following error
File "E:\Softwares\Django-...
I built a a.py in my mysite file,
a.py:
from django.core.management import setup_environ
from mysite import settings
setup_environ(settings)
from django.contrib.sites.models import Site
domain = Site.objects.get_current().domain
print domain
It prints:
:example.com
How do I change the 'domain' to 127.0.0.1:8000?
...
I need a functionality in Django to rotate an image posted by users using a form. I need a method I can maybe put in imageutils.py and then use it in my form.
How can it be achieved?
...
I've got a model called Card which has a ManyToMany relationship to
Tag. When I save a Card, I'd like to create a Product as well, which I
want to have the same ManyToMany relationship to tag.
How do I access the instance's tags? self.tags.all() gives an empty
list, while if I check after saving, the card actually has tags. My
code...
I'm using django-pagination to paginate lists for my Django site. At the top of my template, I'm using
{% autopaginate projects 10 %}
I want to display something like 'Showing 1 - 10 of 52 results'. I know it's easiest to do this with the page objects created by the template tag. The problem is that I don't know how to access it in th...
I am using pylint,
pylint -e app/views.py
Gives me errors like
E: 3: No name 'shortcuts' in module 'django'
E: 7: No name 'db' in module 'django'
But passes for other django imports. Since it passes for other Django import Django is on my pythonpath.
...
What would be the best solution to use a different authentication backend for the Django admin site?
...
I got strange error message when tried to save first_name, last_name to Django's auth_user model.
Failed examples
user = User.object.create_user(username, email, password)
user.first_name = u'Rytis'
user.last_name = u'Slatkevičius'
user.save()
>>> Incorrect string value: '\xC4\x8Dius' for column 'last_name' at row 104
user.first_name ...
I have a problem when I update an object. This is the model:
class HourRecord(models.Model):
day_of_work = models.PositiveIntegerField(max_length=1)
date_of_work = models.DateField(verbose_name='creation date')
who_worked = models.ForeignKey(User)
project = models.ForeignKey(Project, related_name='hour_record_set', null=...
I've just recently switched over to using 64-bit Python 2.6.1 on Mac OS X 10.6 (Snow Leopard). IPython won't work with Django anymore, but IPython works from the command-line.
The error says:
shell = IPython.Shell.IPShell(argv=[])
AttributeError: 'module' object has no attribute 'Shell'
I could use the ./manage.py --plain option...
Hi,
I'm using the contenttypes framework to create a "featured content" feature on my site. I've basically done this by defining a model like so:
class FeaturedContent(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_ty...
Hey,
I want to model the following situation. I have a table of items, and a table of players, and a player can have many items and have multiple copies of the same item. I can easily model the player having multiple items:
class Item(models.Model):
name = models.CharField(max_length = 200, blank = False)
class Player(models.Model...