django-models

Equivalent replacement for ListProperty(db.Key) in djangoappengine

I and trying to use djangoappengine, but I am unsure how can I write model to incorporate standard ListProperty(db.Key) I know that djangotoolbox provides this field types but I am unable to figure out the exact syntax. ...

How to create a table and its related model.py automatically from a csv file in Django

Think of this: You create a CMS of some sort, which asks you for an application name and a csv file for that application. Then it automatically creates that app on the fly, creates the required model.py based on the csv columns, activates the admin page for it and allows only you to have the full permission to this new table via django ...

Django Model retrieval gives wrong type error.

I have a template that has a button that posts just the button's name to a view which has the following code: if request.POST: a = request.POST name = mymodel.objects.get(id = a )[0] return HttpResponse(name) request.POST has the name of the button that submitted the post. THE error is: int() argument must be a string ...

Do a query through a foreignkey in Django

How do I travel through multiple foreign keys in Django? I've tried everything I can think of from the django docs, but I'm obviously missed something (extreme newbie). I have models for scientists, experiments, and theories. If I want to look at a particular Theory (let's call it 'relativity') and get a list of all of the emails of...

Overriding Django Create_object

hi I want to override django.views.generic.create_update.create_object To be more precise when a create is called on an object[here projects] via url eg :http://localhost:8000/projects/create/ i need to check some permissions before the control gets passed to the create_object. I know decorators would help me do it .I tried using dec...

Is it possible to run a django function automatically on certain dates?

Hello, In my django project I would like to be able to delete certain entries in the database automatically if they're too old. I can write a function that checks the creation_date and if its too old, deletes it, but I want this function to be run automatically at regular intervals..Is it possible to do this? Thanks ...

inlineformset_factory composed of ModelForm

Is it possible for an inlineformset_factory to take in a ModelForm as well as a model. When I try to run this I get an error message 'NoneType' object is not iterable. Please help, I've spent an entire day trying to figure this out. Thanks. Code: Model.py class FilterForm(ModelForm): firstFilter = forms.BooleanField(label='First Filt...

Dynamic Django Application Creation Based On a SQL / CSV file

Is there any django application that can create other apps merely based on a sql / csv file provided that a default template is found for the new applications. ...

2 django projects, importing one model from one to another.

My setup is Django 1.2 running via mod_wsgi under Debian Lenny. I have a such structure: /root/ project1/appx models.py project2/appy models.py management/ commands/ mycommand.py Now I want to import Foox model fro...

Assign multiple tags to one entry

I have this simple model: class Tag(models.Model): title = models.SlugField() created = models.datetime def __unicode__(self): return self.title class Entry(models.Model): title = models.CharField(max_length=30) created = models.datetime tags = models.ForeignKey(Tag) categories = models.CharField(max...

Disable verify_exists on models.URLField at runtime?

How can I temporarily turn off verify_exists on a models.URLField at runtime? I would like to skip the check on certain URLs (they block EC2 IPs from their firewall). I'm interfacing with the model through the ModelForm right now. ...

Django models query result is not accurate

Hi I have some problems that has been bothering me for a week. I am running Selenium testing scripts on my dev machine, and in my test I would call simple script to delete accounts by their sub domain names: for a in Account.objects.filter(domain = sub_domain): a.delete() The problem is that the query to find all such accounts are...

Validation fails on a select box whose contents are added by an Ajax call

This question is related to this one http://stackoverflow.com/questions/3340498/remove-all-the-elements-in-a-foreign-key-select-field I had a foreign key field in my model which was getting pre-populated by its data and I wanted the select list to be empty. I did achieve that but the validation fails when I submit the form. The error ...

Django, accessing PostgreSQL sequence

In a Django application I need to create an order number which looks like: yyyymmddnnnn in which yyyy=year, mm=month, dd=day and nnnn is a number between 1 and 9999. I thought I could use a PostgreSQL sequence since the generated numbers are atomic, so I can be sure when the process gets a number that number is unique. So I created a P...

Django model group by datetime's date

Hello Assume I have a such model: class Entity(models.Model): start_time = models.DateTimeField() I want to regroup them as list of lists which each list of lists contains Entities from the same date (same day, time should be ignored). How can this be achieved in a pythonic way ? Thanks ...

Django: Make items in ManyToMany field unavailable once it is "used"?

if this is my models.py: class Category(models.Model): name = models.CharField(max_length=500) slug = models.SlugField(unique=True) def __unicode__(self): return self.name def get_absolute_url(self): return "%s" % self.slug class Item(models.Model): name = models.CharField(max_length...

Get Object count in Django templates

I'm my Django application I'm fetching all the objects for a particular model like so: secs = Sections.objects.filter(order__gt = 5) I pass this varbiles to my templates and i can access all the properties of the Model like section.name, section.id, etc. There is a model called Books which has a FK to the Sections model. When i iter...

Django: Model field for storing a list of floats?

I want to store a variable-length list of floats in Django. There is the CommaSeparatedIntegerField, but is there anything like this that I could use? Would it be best to just implement my own CommaSeparetedFloatField or is there something that I am missing completely? Thanks. ...

Django - Limit users who view the items

My Models: class PromoNotification(models.Model): title = models.CharField(_('Title'), max_length=200) content = models.TextField(_('Content')) users = models.ManyToManyField(User, blank=True, null=True) groups = models.ManyToManyField(Group, blank=True, null=True) I want to publish there items to templates with some p...

Widget filling values in two fields

I know that if I need a custom "selector" for a field in django-admin I need to create a custom widget. But what if the widget have to produce two values, for example X and Y coordinates, how can I fill them in two different fields from the model? ...