Hello,
is it possible to prevent certain fields to be edited after they've been saved?
They should be editable when the user creates a new item of a certain model but then when they try to open them to edit certain fields are 'blocked'.
thanks
...
The title says it all or almost... I have a slug field that I would like to be auto-populated from a value in a manytomany. It kind of works as it displays in realtime the ID of the selection in the manytomany field.
The model of the manytomany field has its own def unicode(self) to return a string value with its name but this doesnt app...
Hi, i've this code:
from django.db import models
class Entry(models.Model):
title = models.CharField(max_length=30,null=False)
body_text = models.TextField(max_length=255)
author = models.ForeignKey(User)
def __unicode__(self):
return self.title
class Meta:
ordering = ('title',)
class User(...
I am still a bit confused about the relation of Proxy models to their Superclasses in django. My question now is how do I get a instance of a Proxy model from an already retrieved instance of the Superclass?
So, lets say I have:
class Animal(models.Model):
type = models.CharField(max_length=20)
name = models.CharField(max_length=...
Is there a way I can serialize a FloatField model instance in django? I have the following in a management command:
def chart_data(request):
i = 1
chart = open_flash_chart()
chart.title = t
for manager in FusionManagers.objects.all():
net_data = manager.netio_set.values_list('Net', flat=True)
clean = seria...
I have a simple-ish ownership design on one of my models. It can be owned by multiple people and current owners can add other people but they have to confirm the invite before they are treated as a real owner.
class MyOwnedThing(models.Model):
owners = models.ManyToManyField(User, through='Ownership', related_name='othings')
de...
When I make a change to my models (only to add a column during development!), Django won't issue any ALTER TABLE statements to update the database. Is there a way to get this implemented or worked around? - other then adding the columns manually?
Note I'm not really looking for a full-migration solution, just something that lets me ke...
I was wondering how they made it possible to display more fields in the User page of the djagno admin site.
If you create a new User you only have some basic fields to fill in but if you reopen that user (edit mode) then you see a lot more fields to fill in.
Im trying to achieve the same, I had a look at the add_form.html template but I...
I have a ManyToMany field with a relationship model. I want a formset, filtered on one of the
keys, which shows a form for each of the other keys.
My guess is that a custom manager on the relationship model is the key to solving this problem. The manager would return "phantom" instances initialized with the appropriate ForeignKey when n...
I have finally got my admin part of my django site working.
I am now beginning the tedious part of manually entering the initial data into the database. Obviously, I want this to be a one time affair.
Can anyone suggest to me how I can create fixtures data from my manually entered data, so that I can reload the data (automatically?) wh...
My site has two types of users; customers and suppliers. I have ended up with the following class structure:
class Customer(models.Model):
# stuff specific to customers
class Supplier(models.Model):
# stuff specific to suppliers
class Profile(models.Model): # returned by Django's User.get_profile()
user = models.ForeignKe...
For a number of reasons^, I'd like to use a UUID as a primary key in some of my Django models. If I do so, will I still be able to use outside apps like "contrib.comments", "django-voting" or "django-tagging" which use generic relations via ContentType?
Using "django-voting" as an example, the Vote model looks like this:
class Vote(mod...
Hi guys,
how do i use the models to perform a join and count query like the one below:
select count(*),site_url from connection_ss
join site_ss on to_id_id = site_id
where site_ss.source_id = 1 group by site_url order by count desc
Here are my models:
class site(models.Model):
site_id = models.AutoField(primary_key=...
Hey Guys,
How would you go about making a pluggable django app, that can accept data from any model and then perfom some action with that data (i.e Save to DB, Send email). This functionality should be generic and should not be tied to a specific model.
...
When running a Django unit test, it try's to install a fixture (initial_data.json) to the db, but fails everytime due to Runtime Error: maximum recursion depth exceeded while calling Python object
Any idea what's going on?
Edit: Django 1.2.3 and Python 2.7
...
I have a form that submits the following data:
question[priority] = "3"
question[effort] = "5"
question[question] = "A question"
That data is submitted to the URL /questions/1/save where 1 is the question.id. What I'd love to do is get question #1 and update it based on the POST data. I've got some of it working, but I don't know how ...
i wanted to place the foo/view code below into a property under the Foo model object, but the debug message says 'bar' cannot be found. Why does it work in the views.py, but not work when i place it in models.py( i did remember to import Bar)?
thanks!
foo/models.py
class Foo(models.Model):
title = models.CharField(_(u'Title'), max_l...
If you have tens of thousands of objects, raw_id_fields is necessary. But knowing the ID of any specific object is not realistic. However most people would be able to remember the keywords of an object's slug, or in my case, maybe a unique 'sku number'. Is there a way to make 'raw_id_fields' search by sku or slug?
...
I've got a Django class like this:
class Breakfast(m.Model):
# egg = m.OneToOneField(Egg)
...
class Egg(m.Model):
breakfast = m.OneToOneField(Breakfast, related_name="egg")
Is it possible to have breakfast.egg == None if there is no Egg related to the Breakfast?
Edit: Forgot to mention: I'd rather not change the related_...
I dam trying to do this:
http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name
Using this style
This is saved as common/abstract.py
class OtherModel(models.Model):
something = Charfield(max_length=100)
class Meta:
abstract = True
class Base(models.Model):
fk_model = models.Fo...