django

Why do I get an object is not iterable error?

Why do I get the following error in my app Caught TypeError while rendering: 'ModelNameHere' object is not iterable but I don't get it when I execute it from the shell? I just have a custom field in my form which inherits from forms.ModelForm custom_serving_size = forms.ChoiceField(ServingSize.objects.all(), widget=forms.Select(attr...

Possible to send 2 querysets to response?

Hi, render_to_response Is it possible to pass more variables than just one? For example in my application I have a members model and then i would like to display the members information and also attendance information. Would I have to supply the arguments as a tuple? Thanks in Advance, Dean ...

Automatic creation date for django model form objects?

What's the best way to set a creation date for an object automatically, and also a field that will record when the object was last updated? In my model I have: created_at = models.DateTimeField(False, True, editable=False) updated_at = models.DateTimeField(True, True, editable=False) and in my view: if request.method == 'POST': ...

Django CMS 2.1.0 App Extension NoReverseMatch TemplateSyntaxError

I'm writing a custom app for Django CMS, but get the following error when trying to view a published entry in the admin: TemplateSyntaxError at /admin/cmsplugin_publisher/entry/ Caught NoReverseMatch while rendering: Reverse for 'cmsplugin_publisher_entry_detail' with arguments '()' and keyword arguments '{'slug': u'test-german'...

Working programmatically with an HTTPResponse in Django

I am working on an app which would enable a preview function for a model. Models marked as preview-able would allow for changes to be made in the Django admin interface and previewed on site using the same view as would an object of that type normally use to render itself, but rendered instead with the new (unsaved) object in it's place....

Django update table

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 ...

Using Django settings in templates

Hi, I want to be able to put certain configuration information in my settings.py file - things like the site name, site url, etc. If I do this, how can I then access those settings in templates? Thanks ...

MVC Webframeworks

Possible Duplicate: Choosing a Java Web Framework now? I know that Ruby-on-Rails and Django are 2 MVC oriented webframeworks, in Ruby and Python respectively. Are there any other MVC frameworks ? Any MVC frameworks that use Java ? ...

Hot to reuse table header sort feature of Django admin?

Is possible to reuse the table header sort feature of the admin forms in my own views and templates? ...

Connecting a django-registration signal

I have a function: def create(sender, **kw): [...] Which should be called when the user_activated signal from django-registration is called. I connect the signal and the function using this: from registration.signals import user_activated [...] post_save.connect(create, sender=user_activated, dispatch_uid="users-atactivation-signa...

Socket permissions when running Django with FastCGI

I am running Django fcgi with standard line: exec setuidgid $USERID $VENVBIN/python $WEBAPP/manage.py runfcgi daemonize=false socket=$FCGISOCKET Problem is that only group is shared between fastcgi process and webserver, not user - however group do not have write permissions by default (hotfix is running chmod g+w manually). How to f...

files getting wrongly cached by the web server while using standard python file operations (Django)

I have a Django app, which populates content from a text file, and populates them using the initial option in a standard form. The file gets updated on the server, but when the form gets refreshed, it picks up content from the a previously saved version, or the version before the Apache WebServer was reloaded. This means that the file i...

password reset form, own clean method

I want to write my own method for the password reset form to make some tests about the new password (length, characters,...). So I added this class to my forms.py: class PasswordResetForm(SetPasswordForm): def clean(self): if 'newpassword1' in self.cleaned_data and 'newpassword2' in self.cleaned_data: if self.cleaned_data['n...

Can Django pre_save signal work for all derived classes

I have a model class "Action" that get's extended by several other classes. I am new to django and assumed that if I called pre_save.connect(actionFunc, sender=Action) that actionFunc would get called anytime the save method in the Action class was called (including by any derived class). My observation is that this function only ge...

Generating custom forms from DB schema

Hi, I am a current web2py user, but find I still go back to Django once in a while (where I started). Specifically when working on projects where I want to make use of some specific django apps/plugins/extensions that don't yet exist in web2py. One thing that I can't live without in web2py, which I am looking for a solution for in Dja...

Why Does Specifying choices to a Widget not work in ModelForm.__init__

Hi, I'm trying to understand why I can't specify choices to a form field's widget if I'm overriding a ModelForm's field in Django. It works if I give the choices to the field but not the widget. My understanding is/was that if you give choices to a field it'll be passed onto the widget for rendering. I know I can get this to work with a...

Elegant way to count frequency and correlation of many-to-many relationships with Django ORM?

Hi I have a Pizza model and a Topping model, with a many-to-many relationship between the two. Can you recommend an elegant way to extract: the popularity (frequency) of each topping the correlation between toppings (i.e. which sets of toppings are most frequent) Thanks ...

Simple Django validation with multiple parameters issue

Hi everyone, I've been playing with Django for a couple of days and stumbled upon the following issue. I have the following models: Employee = (id, employeeName) Project = (id, projectName) Assignment = (fk_employee, fk_project, from_date, to_date) What I want to do is to create a validator that won't allow assignment periods to overl...

Django Haystack substring search

I have recently added search capabilities to my django-powered site to allow employers to search for employees using keywords. When the user initially uploads their resume, I turn it into text, get rid of stop words, and then add the text to a TextField for that user. I used Django-Haystack with the Whoosh search back engine. Three thin...

Python MySQL and Django problem

I am having problems getting python/django to connect to a MySQL database. The error message is basically "Error Loading MySQLDb module: No module named MySQLDb". This is a fresh install right off python.org, so I assumed that it would have the MySQLDb module included, but it does not seem to. I also can't seem to find the module or how...