I'm trying to model a "what's hot right now" like function for a video library (i.e a Most-viewed related to time - Clustering views (in time) will cause a higher rating), but I can't quite get my head around how do to it properly in Django without causing a multitude of database queries. I realize there's no one right answer to this, bu...
I'm trying to optimize the database calls coming from a fairly small Django app. At current I have a couple of models, Inquiry and InquiryStatus. When selecting all of the records from MySQL, I get a nice JOIN statement on the two tables, followed by many requests to the InquiryStatus table. Why is Django still making individual reque...
A client wants to ensure that I cannot read sensitive data from their site, which will still be administered by me. In practice, this means that I'll have database access, but it can't be possible for me to read the contents of certain Model Fields. Is there any way to make the data inaccessible to me, but still decrypted by the server t...
Let's say I have two models looking like this:
class ProductType(models.Model):
product_type = models.CharField(max_length=100)
class Product(models.Model):
name = models.CharField(max_length=200)
slug = models.SlugField()
product_type = models.ForeignKey(ProductType)
score = models.PositiveIntegerField(default=0...
Hello, I want to extend the admin panel of Django where adding/changing happens for a specific object, say Foo.
I have already done alot of research and found a part discussing this at the old version djangobook.
I have made an admin/myapp/foo/change_list.html at my template directory and did some experient such as adding some html and ...
I would like to use properties from an inheriting model's Meta class to configure a field defined in an abstract model higher up the inheritance tree:
class NamedModel(models.Model):
class Meta:
abstract = True
verbose_name = 'object'
name = models.CharField("Name",
max_length=200,
db_index=True,...
Hi guys, I would like to learn how to work with the Django Admin. How do I know when the user is editing an existing object or saving a new object?
For example, if I want to make a function to do something different when the user saves a new object or saves an edited object, how do I know which is which?
Thanks guys :)
Sorry for my E...
Hi (please, excuse me for my ugly english) !
Imagine these very simple models :
class Photo(models.Model):
is_public = models.BooleanField('Public', default=False)
class Gallery(models.Model):
photos = models.ManyToManyField('Photos', related_name='galleries', null=True, blank=True)
I need to select all Gallery instances whi...
Hi!
I am creating simple application with django. Also, I realized that I am doing some kind of operations very often. For example I often need to get all Article objects which have isPublick = True. So I am thinking is that possible to define get_published function in model?
if models looks like this (simplified)
class Article(models...
Hi (excuse me for my bad english) !
When I make this:
gallery_qs = Gallery.objects.all()\
.annotate(Count('photos'))\
.extra(select={'photo_id': 'photologue_photo.id'})
The sql query is :
SELECT (photologue_photo.id) AS `photo`, `photologue_gallery`.*
FROM `photologue_gallery`
LEFT OUTER ...
I'm trying to figure out the best way to derive a nested menu from a set of non-nested models. Given a layout something like this:
class Beverage(models.Model):
country = models.ForeignKey(Country,null=True,blank=True)
region = models.ForeignKey(Region,null=True,blank=True)
subregion = models.ForeignKey(SubRegion,null=True,...
Hi guys, there is something that i would like do.
i have 4 class:
class delivery(models.Model):
name= models.CharField(max_length=100)
date_join= models.DateField()
....
class Town(models.Model):
delivery_guy = models.ForeignKey(delivery)
name = models.CharField(max_length=100)
....
class...
H guys, Django admin, all section (menu links) come form models with database table, but, what happen if i need a section without model (no database table) that bring me data from other section with model?
Any idea?
Thanks
...
I have a such model named Foo:
class Foo(models.Model):
name = models.CharField()
entry = models.DateField()
I have 2 types of users who can login to the admin panel, regular and superusers. I want to disallow the edition/deletion of Foo entries that are older than 2 days (by using the entry date field) but superusers may edi...
Hi
I have a website which fetches information from RSS feeds periodically (well, currently manually, and this is my problem). This is currently implemented as a normal Django view, which isn't very nice in my opinion. I'd like to have a Python program which is run using a cronjob instead of manually visiting the correct URL to update ...
Hello,
I want to store events in a web application I am fooling around with and I feel quite unsure about the pros and cons of each respective approach - using inheritance extensively or in a more modest manner.
Example:
class Event(models.Model):
moment = models.DateTimeField()
class UserEvent(Event):
user = models.ForeignKe...
I'm using Django-Registration and the form just has 3 fields (Username, Email, Password, and Re-password), but why I can't add last name and first name??
In the Form all is fine but the User Model just accepts 3 arguments:
new_user = User.objects.create_user(username, email, password)
but why I can't do that:
new_user = User.objects...
Imagine for a moment that I have a system that allows users to take notes. I've got a User model and a Note model:
class User(models.Model):
name = models.TextField()
class Note(models.Model):
contents = models.TextField()
user = models.ForeignKey(User)
created_at = models.DateTimeField(auto_now_add=True)
I'd like to ...
I have :
class Award(models.Model) :
name = models.CharField(max_length=100, db_index=True)
class Alias(models.Model) :
awards = models.ManyToManyField('Award', through='Achiever')
class Achiever(models.Model):
award = models.ForeignKey(Award)
alias = models.ForeignKey(Alias)
count = models.IntegerField(default=1)
...
Here is a Django model I'm using.
class Person(models.Model):
surname = models.CharField(max_length=255, null=True, blank=True)
first_name = models.CharField(max_length=255, null=True, blank=True)
middle_names = models.CharField(max_length=255, null=True, blank=True)
birth_year = WideYear(null=True, blank=True)
birth...