Hi guys, im want to know if there is any way to make a SlugField unique for Any field different to pub date?
for example i would like a slug unique (city field) for a field called country
any idea?
thanks
...
I'm trying to create form, for adding new friend/updating existing one. My first solution uses ModelForm, but data from updated form are not saved. Also problem is that my model has CharFields ('code', 'pid'), that I need to validate with regex through my form. If I exclude those fields in Meta, and add them to the FriendForm, when the f...
hi
i have to update an entry in my django model
i have used force_update in save method like this
register = rform.save(commit=False)
register.user = request.user
register.save(register.user,force_update=True)
but it gives me an error
"ValueError at /status/
Cannot force both insert and updating in model saving."
how to solve this...
I'm open to persuasion that this is a bad idea. But if not, here's the general draw:
Web interface to maintain data (django.contrib.admin).
Web interface to create pages (django.contrib.flatpages)
Web interface to create templates (dbtemplates)
Where is the web interface to create queries and define context? (contexts?)
EDIT
Here...
Hi,
I have the following model:
class Program(models.Model):
name = models.CharField(max_length = 128)
def __unicode__(self):
return self.name
class Cheat(models.Model):
program = models.ForeignKey(Program)
shortcut = models.CharField(max_length = 64)
description = models.CharField(max_length = 512)
def ...
I have a Django model Reminder related to Event model.
class Reminder(models.Model):
email = models.EmailField("e-mail")
event = models.ForeignKey(Event, unique=True, related_name='event',)
date = models.DateTimeField(_(u"Remind date"), auto_now_add=False,)
class Event(models.Model):
date = models.DateTimeField(_(u"Even...
I am hoping to to build a model for a single table that houses different types of "articles" (for argument's sake).
Each article will have MOSTLY common fields (e.g. title, date etc.) but there are cases where some article types (outside of my control) have slightly different field requirements and respective validation rules . No fie...
I have Django model that looks like this:
class Categories(models.Model):
"""
Model for storing the categories
"""
name = models.CharField(max_length=8)
keywords = models.TextField()
spamwords = models.TextField()
translations = models.TextField()
def __unicode__(self):
return self.name
clas...
I'm new to django.
I have 2 simple objects, lets call them - File and FileGroup:
- A FileGroup can hold a list of files, sorted according to an 'order' field.
- Each file can be associated with multiple groups.
so basically, the db tables would be:
1) File
2) File_Group
3) File_Group_Mapping table that has a column named "order" in add...
I have a Django model that looks like this:
class Categories(models.Model):
"""
Model for storing the categories
"""
name = models.CharField(max_length=8)
keywords = models.TextField()
spamwords = models.TextField()
translations = models.TextField()
def save(self, force_insert=False, force_update=False):
...
http://code.google.com/p/django-multilingual-model/
I am trying to understand how the multilanguage feature works and i found the example in the above link
What i have done is i have created a project as test and included that in settings.py
And in the test directory i have the multilingual.py and the code for this is the above said ...
Hi all,
It's simple - All I want to do is set who answered the question if the question is answered. Can someone please enlighten me on how to set a form value if the question was answered. I know that I could also set this as an initial value but then I have to selectively determine which records were answered. This seemed simpler bu...
Hi I am creating a trouble ticket app for my company, and I want to redirect the user to a new form where he will specify the diagnose and solution he offered.
my admin is
Basically, Right now my code is calling the first form, when the obj created is new or the status is open and it is calling the ClosedForm when my status is closed.
...
I want to define two model fields: created_by, modified_by in a parent model, they will be acting as common fields for the child models.
class ExtendedModel(models.Model):
created_by = models.ForeignKey(User,related_name='r_created_by')
modified_by = models.ForeignKey(User,related_name='r_modified_by')
class Meta...
What is the link to find the list of languages i.e, language_code
(Swedish,sv)
(English,en) ..........
Please provide the link
Thanks..
...
Hi folks,
I'm just wondering if there is any example I could take from others on the topic.
I have a page within Django which uses filters, in order to perform searches.
At the moment I'm doing a simple check for the GET parameters and adding a .filter() to a queryset accordingly:
if color:
query.filter(color=color)
This feels ...
Hi,
Django does not respect the max_length attribute of TextField model field while validating a ModelForm.
So I define a LimitedTextField inherited from the models.TextField and added validation bits similar to models.CharField:
from django.core import validators
class LimitedTextField(models.TextField):
def __init__(self, *arg...
How do I guarantee data only gets saved when the related objects are both filled with data?
class A(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField()
class B(A):
author = models.CharField(max_length=255)
url = models.URLField()
I insert data by accessing model B:
b = B()
b.title = 'ti...
I have a django application where i'll like to have a script that i'll run once a day to validate the models in the database, and delete some objects. How cand i make it ? I want something equivalent to rake:task in rails.
...
Are model save() methods lazy in django?
For instance, at what line in the following code sample will django hit the database?
my_model = MyModel()
my_model.name = 'Jeff Atwood'
my_model.save()
# Some code that is independent of my_model...
model_id = model_instance.id
print (model_id)
...