I want to generate a queryset to find mismatches. As an example
class Vehicle(models.Model):
car = models.CharField(max_length=100)
model= models.CharField(max_length=100)
passengers = models.IntegerField()
i want to generate a query where i can find cars erroneously listed with two different models.
something along th...
Hi all,
Before you all point me to here and here mine a bit different. So I started getting the famous error after shifting to my production server.
django/db/backends/mysql/base.py:86: Warning: Data truncated for column 'slug' at row 1
The first thing I did was start googling this after I fixed the problem. To fix this, I tweak...
My site makes use of Django's User Authentication User model and a custom UserProfile model to store some additional data (birthday, etc.). Is there a way to create a view in Django admin that weaves together fields from both the User and UserProfile models?
I suspect that this code snippet is not even close, but maybe it will help illu...
This may not be relevant but just wanted to ask,
IF an object is passed from views to template and in the template will i be able to query many to many fields
Models code:
class Info(models.Model):
xls_answer = models.TextField(null=True,blank=True)
class Upload(models.Model):
access = models.IntegerField()
info ...
I registered an app to the django admin with:
from django.contrib import admin
from MyProject.myapp.models import Model1, Model2
class HyperlinkAdmin(admin.ModelAdmin):
pass
class Model2Admin(admin.ModelAdmin):
pass
admin.site.register(Hyperlink, HyperlinkAdmin)
admin.site.register(Model2, Model2Admin)
Model1=
class Hyperlink...
I'm wondering what is the best way to model something like the following.
Lets say my company sells metal bars (parameters/fields are: length, profile_type, quantity etc.) of different profiles, where profiles may be pipe(pipe_diameter, wall_thickness) or hollow_rectangle(base, height, wall_thickness), or maybe some other profile with d...
Suppose I have these two models:
class Blog(models.Model):
name = models.CharField(max_length=64)
# ...
class Entry(models.Model):
blog = models.ForeignKey(Blog)
added = models.DateTimeField(auto_now_add=True)
# ...
Now I want to get a list of all blogs along with the latest blog entry for each respective blog. Wh...
I have an app that makes use of 'django-registration' a custom built model named 'idea' and also a 'userprofile'
Now the Idea class looks as follows
class Idea(models.Model):
title = ...
user = models.ForeignKey(User)
The User class is Django's Auth User system.
And the UserProfile looks as follow.
class UserPro...
obj = Info(name= sub,question=response_dict["question"])
obj.save()
After saving the data how to update another field of the same table
obj.err_flag=1
obj.update()//Will this work
...
I have a simple Book Author relationship
class Author(models.Model):
first_name = models.CharField(max_length=125)
last_name = models.CharField(max_length=125)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Book(models.Model):
title = models.CharField(max_length...
I want to add a column to a database table but I don't want to modify the 3rd party module in case I need/decide to upgrade the module in the future. Is there a way I can add this field within my code so that with new builds I don't have to add the field manually?
...
ORM tools are great when the queries we need are simple select or insert clauses.
But sometimes we may have to fall back to use raw SQL queries, because we may need to make queries so complex that simply using the ORM API can not give us an efficient and effective solution.
What do you do to deal with the difference between objects ret...
I'm working on a logging app in Django to record when models in other apps are created, changed, or deleted. All I really need to record is the user who did it, a timestamp, a type of action, and the item that was changed. The user, timestamp, and action type are all easy, but I'm not sure what a good way to store the affected item is be...
My models:
class Entry(models.Model):
title = models.CharField(_('Title'), max_length=200)
content = models.TextField(_('Content'))
created_at = models.DateTimeField(auto_now_add=True)
My models is used for multi-user. So, how to set a value to handle minimum time between posts? Please give me some codes. Thanks so much!
...
Hi all,
I need your advice on managing a Django application as it grows in terms of features and models.
For instance as a application grows, we often need to add in new features.
Adding new features involves adding new models, or adding a new field within a model.
How would you go about doing that without closing the web application...
After uploading a file from the UI, how to create the a new directory with the current timestamp in /opt/files/ and copy the uploaded zip file to this directory, and unzip the zip file in the new directory and maintain the new directory name in a variable
def upload_info(request):
if request.method == 'POST':
fi...
This is a follow-up to this question. How do I display properties defined on a child model in an inline on the parent? To illustrate, I have this model:
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True, primary_key=True, related_name='profile')
...
@property
def age(self):
if self.birth...
Hi folks,
is it possible to mark some fields/rows red in django admin interface if they achieve a expression?
For example, if there is a model "Group" with members and capacity, how can I visualize when they are full or crowded?
...
Hi. I was wondering if something can shed some light on where I might be going wrong with this.
I need to generate a signed Key for use with Gigya an openauth platform
This is a rework from their Ruby info,
http://wiki.gigya.com/020_Developer_Guide/70_Server_Side_API_(REST)#tab-2
Here is what I have thus far.
#@ escape the status mes...
How to decode the values from request from django FW.
GET:<QueryDict: {}>,
POST:<QueryDict: {u'objarrid': [u'1035', u'1036', u'1037', u'1038', u'1039', u'1040', u'1041', u'1042']}>,
def get_data(request):
try:
if request.method == 'GET':
r_c = request.GET
elif request.method == 'POST':
r_c = request.POST
except:...