django

How can I set arbitrary attributes on Django Model Fields, then access them in a ModelForm?

What Django Does Django's Model Field "blank" attribute, and the way it gets negated and turned into the Form Field "required" attribute when you create a ModelForm, is pretty cool. It allows me to set the property on the model where it belongs, but have the "required" attribute available when handling a ModelForm created from it. Havin...

Organizing Django + Static Website Folder Hierarchy

I'm currently working on developing a personal Django site that will consist of various technologies / subdomains. My main page(s) will be Django, with a blog.blah.com subdomain that runs wordpress, and several other subdomains for projects (project1.blah.com, project2.blah.com), that are static HTML files (created with Sphinx). I'm hav...

Including a third party python package in Django on app-engine.

I have a django app running on appengine and it works fine. Now I want to extend it to use a third party python package - googleanalytics. No matter where I put this package django complaints about not finding it (Error was: No module named googleanalytics). My dir structure is as follows- app.yaml myproject   -settings.py   -manage.py...

Django thumbnails suggestion

Looking for an alternate to django-imagekit. django-imagekit with django-cumulus causes loads of timeout issues and makes apps very inconsistent. Are there any alternatives that you can suggest that you have used in your previous projects? ...

how can i get a next form/page while each submitting form ??

i am working with a django quiz application where one question per page. when i will answer one question selecting a radio button and click submit button how can i get the next question in the next page as well as the answer will submitted to database. If anyone help me it would be an outstanding solution for me. please I wrote a view to...

Access Model Data from Django Base Template

I have a model Category, and I want its objects to always be displayed in a navigation menu in my base.html template (which all of my other templates extend). I want to learn best-practices so would like to know what the correct/accepted way of providing this data to the template is. ...

Sphinx documentation on Django templatetags

I am using Sphinx with autodoc for documenting my Django project. Design guys want to have documentation page(s) about all the template tags that are defined in the project. Of course, I can make such a page by enumerating all the template processing functions by hand, but I think it is not DRY, isn't it? In fact, template tag processin...

Caught NoReverseMatch while rendering with generic PasswordChangeForm Django view

I'm trying to use the generic PasswordChangeForm and password_change view in Django, and running into a NoReverseMatch error. Here is my urls.py: (r'^change_pass/','django.contrib.auth.views.password_change', {'post_change_redirect':'/home'}), Then, I'm trying to call the following from the template: <form action="{% url django....

Django: preventing direct access to files

I want to serve files dynamically from behind the root of my web directory. Currently I'm serving all the files statically which I did just in order to include my javascripts and css files. I realize this is probably dumb but I'm not able to serve files any other way! So, I want to serve files dynamically, without the user being able ac...

Filtering related fields in django's annotate() feature

The Django documentation gives examples for using annotate() to produce aggregate results based on related fields of a QuerySet (i.e., using joins in annotate()). A simplified example from the docs is for instance Store.objects.annotate(min_price=Min('books__price')), where books is a ManyToMany field of Store to Book and price is a fie...

Make inlineformset in django required

Hi, I am new to django (until now, I used the symfony PHP Framework). My problem is this: I have a model Event and model Date. The Date has a foreign key to Event, so that an Event may (or should) have one or more Dates. Now I want to have a form to create Events and this form should include a subform for adding one corresponding Date ...

Want to restrict choices to a subset of rows

I'm working on a video management application where each video clip is associated with a single program-name and a single category-name, but programs and categories can be associated with multiple different videos. (This part is straight forward.) What's different is that the choices for category-names vary on a per program basis. For ...

Is it possible to instruct Django to save a model instance to a particular table based on its fields?

I'm attempting to construct a Django application that models an existing set of tables. These tables all have the same fields, plus custom fields per table. What I'm wanting to do is model this structure, and have records save to a particular table based on what table model they are attached to. These tables can be created quite often,...

Django ORM: count a subset of related items

I am looking to find a way to annotate a queryset with the counts of a subset of related items. Below is a subset of my models: class Person(models.Model): Name = models.CharField(max_length = 255) PracticeAttended = models.ManyToManyField('Practice', through = 'PracticeRecord') cl...

Externally add form errors in Django

Hi all, I have a Django form that will add an entry to a database with a unique constraint on one of the columns. If the submission happens to attempt creation of a duplicate, I get a django.db.utls.IntegrityError stating I violated the unique constraint (thankfully). When processing Django forms, there are a number of ways to valid...

django: datediff sql queries?

I'm trying to do the equivalent of the following SQL in Django: SELECT * FROM applicant WHERE date_out - date_in >= 1 AND date_out - date_in <= 6 I can do this as a RAW sql query, but this is becoming frustrating in dealing with a RawQuerySet instead of a regular QuerySet object as I would like to be able to filter it later in the code...

Geodjango with Geonames

I would like to implement a location based search, based on the geonames zip code dump. For that, I want to use geodjango, but I have no idea how to implement the geonames data for lookup. I don't want to use an external webservice. Maybe someone already has realized that and has some inspirations for me? ...

How to use 2 diffrent authentications in a django-powered site?

I currently manage a website, coded in django, that has 2 standard areas - the frontend and backoffice (which is built using django's admin interface). Recently the customer claimed he wanted 2 diffrent authentications - one for frontend users and another one - for people managing the backoffice. Until now they both used standard djan...

Django - Form widget with a checkbox to choose between unlimited or a textbox for a number

I am making a form in Django. The field to display is a numeric field representing some limit. It's possible for there to be no limit. Rather than force the user to enter some strange number to mean unlimited (e.g. -1), I'd like there to be a radio button, with 2 options: "Unlimited" and the second option being a text box that the user c...

programmatically log into Yahoo/MSN(Hotmail) using python Django code and get the contact list ?

Is there a way to programmatically log into Yahoo!, providing email id and password as inputs, and fetch the user's contacts? I've achieved the same thing with Gmail, using BeautifulSoup.py Yahoo Address book API provides BBAuth, which requires the user to be redirected to Yahoo login page. But I'm looking for a way to authenticate the...