Can I force the first letter of the verbose_name of a django model field to be lower case?
Django automatically capitalizes the first letter of the verbose_name of a field in a model. I'd like it to be lower case. Is there a way to do that? ...
Django automatically capitalizes the first letter of the verbose_name of a field in a model. I'd like it to be lower case. Is there a way to do that? ...
Some model fields such as DateTimeField require null=True option when blank=True option is set. I'd like to know which fields require that (maybe dependent on backend DBMS), and there is any way to do this automatically. ...
One of my models which has ForeignKey's is actually a MySQL view on other tables. The problem I'm running into is that when I delete data from these tables, Django, as described in the "deleting objects" documentation... When Django deletes an object, it emulates the behavior of the SQL constraint ON DELETE CASCADE -- in other ...
2 questions: How can I stop duplicates from being created when parent=None and name is the same? Can i call a model method from within the form? Please see full details below: models.py class MyTest(models.Model): parent = models.ForeignKey('self', null=True, blank=True, related_name='children') name = models.CharField(max...
I'm a PHP guy on my first day in Python-land, trying to convert a php site to python (learning experience), and I'm hurting for advice. I never thought it would be so hard to use multi-dimensional arrays or dictionaries as you pythoners call them. So I can create multi-dimensional arrays using this, but i can't loop it in a django templ...
How can you know if a value is the default value for a Model's property. For example class Alias(models.Model) : image = models.ImageField(upload_to='alias', default='/media/alias-default.png') a = Alias.get("123") # this doesn't work if a.image == a.image.default : pass # nor this if a.image == Alias.image.default : pass I t...
View categories = Category.objects.all() t = loader.get_template('index.html') v = Context({ 'categories': categories }) return HttpResponse(t.render(v)) Template {% for category in categories %} <h1>{{ category.name }}</h1> {% endfor %} this works great. now im trying to print each company in that category. the company table...
How can I have different users for different sites with django. My application should look like this: a.mydomain.com b.otherdomain.com Users should be bound to the domain, so that a.mydomain.com and b.otherdomain.com have different users. ...
I was having a debate on this with some colleagues. Is there a preferred way to retrieve an object in Django when you're expecting only one? The two obvious ways are: try: obj = MyModel.objects.get(id=1) except MyModel.DoesNotExist: # we have no object! do something pass and objs = MyModel.objects.filt...
Hello people, I would like to add a field to the Django FlatPage database model, but I do not really know how to extend this without editing the original application. What I want to do is to add the following field to the model: from django.db import models from django.contrib.flatpages.models import FlatPage as FlatPageOld class Fl...
I'm using the row-level permission model known as django-granular-permissions (http://code.google.com/p/django-granular-permissions/). The permission model simply has just two more fields which are content-type and object id. I've used the following query: User.objects.filter(Q(row_permission_set__name='staff') | \ Q(row_permissi...
Hello, I'm using the following setup to implement soft deletes in Django. I'm not very familiar with Django under the hood so I'd appreciate any feedback on gotchas I might encounter. I'm particular uncomfortable subclassing a QuerySet. The basic idea is that the first call to delete on a MyModel changes MyModel's date_deleted to t...
How I can Update the row ionto database using ADo.net Data Entity Model ...
I am trying to use different open source apps in my project. Problem is that there is a same Model name used by two different apps with their own model definition. I tried using: class Meta: db_table = "db_name" but it didn't work. I am still getting field name clash error at syncdb. Any suggestions. Update I am actual...
I saw the former question can i use a database view as a model in django and try it in my app,but that's not work.I create a view named "vi_topics" manually and it had "id" column。But I always got the error about "no such column: vi_topics.id",even I add "id" field explicitly. here is my view models : from django.db import models cl...
i'm writing a data migration using south... but the question refers to the use of select_related to retrieve many to many fields. the documentation specifies that select_related can be used for fields with relationships using ForeignKey ... i can't fathom it wont' work with ManyToMany fields right? my field have blank=null but the docu...
I am making a system for a company which among other things must hold information about the satisfactory level about various things, I have made it work fine using a fixed model with fixed questions and answers, but I am sure that they will need to change or add questions. So I want to make a system where users can make custom evaluatio...
Hello. I have the following classes in my models file class HardwareNode(models.Model): ip_address = models.CharField(max_length=15) port = models.IntegerField() location = models.CharField(max_length=50) hostname = models.CharField(max_length=30) def __unicode__(self): return self.hostname class Subscripti...
Hello, I am developing a web application and I am wondering if someone has a full read-only access to my filesystem, can this person (assuming that he is aware of everything necessary) have a write access to the system? For example, if you have a PHP script that outputs contents of any files on the server - will someone really be able ...
Lets say I have model inheritance set up in the way defined below. class ArticleBase(models.Model): title = models.CharField() author = models.CharField() class Review(ArticleBase): rating = models.IntegerField() class News(ArticleBase): source = models.CharField() If I need a list of all articles regardless of type ...