django

django select box size option

I have three drop down select boxes, which I have to expand for web visibility reasons with the size='' option. If I select one from each box I receive no errors, but if I leave one or more boxes without a selection I receive an error. {% for pathology in pathology_list %} {{ pathology.pathology }} {% endfor %} ...

Do I need server-end knowledge (e.g. Django, Rails), if I want to do Javascript, AJAX stuff?

Hi People, I am trying to get into web development, specially interested building the front-end, UI part of websites while learning JavaScript maybe with AJAX technology. (I have a UI, HCI background.) However, I have absolutely no previous knowledge about server-end web development either. To my understanding, frameworks like Django s...

Creating an order in Django

Hi everyone I have a few questions about the django admin. First the relevant details. I currently have Client, Printer, Cartridge, and Order models. The Printer model has a ManyToManyField to the Cartridge model, which would allow you to select all the cartridges that can be used with that printer. The Cliente has a ManyToManyField t...

Django Shell shortcut in Windows

I'm trying to write a bat file so I can quickly launch into the Interactive Shell for one of my Django projects. Basically I need to write a python script that can launch "manage.py shell" and then be able to print from mysite.myapp.models import * The problem is manage.py shell cannot take additional arguments and launching into "mana...

how to sort by a computed value in django

Hey I want to sort objects based on a computed value in django... how do I do it? Here is an example User profile model based on stack overflow that explains my predicament: class Profile(models.Model): user = models.ForeignKey(User) def get_reputation(): ... return reputation reputation = property(get_rep...

fetching single child row based on a max value using Django ORM

I have a model, "Market" that has a one-to-many relation to another model, "Contract": class Market(models.Model): name = ... ... class Contract(models.Model): name= ... market = models.ForeignKey(Market, ...) current_price = ... I'd like to fetch Market objects along with the contract with the maximum price of ea...

Search functionality for Django

I'm developing a web app using Django, and I'll need to add search functionality soon. Search will be implemented for two models, one being an extension of the auth user class and another one with the fields name, tags, and description. So I guess nothing too scary here in context of searching text. For development I am using SQLite and...

Generic many-to-many relationships

I'm trying to create a messaging system where a message's sender and recipients can be generic entities. This seems fine for the sender, where there is only object to reference (GenericForeignKey) but I can't figure out how to go about this for the recipients (GenericManyToManyKey ??) Below is a simplified example. PersonClient and Comp...

Django-like abstract database API for non-Django projects

I love the abstract database API that comes with Django, I was wondering if I could use this (or something similar) to model, access, and manage my (postgres) database for my non-Django Python projects. ...

Django - ORM question

Just wondering if it is possible to get a result that I can get using this SQL query with only Django ORM: SELECT * FROM (SELECT DATE_FORMAT(created, "%Y") as dte, sum(1) FROM some_table GROUP BY dte) as analytics; The result is: +------+--------+ | dte | sum(1) | +------+--------+ | 2006 | 20 | | 2007 | 2230 | | 2008 | 49...

Custom Markup in Django

Can anyone give me an idea or perhaps some references on how to create custom markups for django using textile or Markdown(or am I thinking wrong here)? For example: I'd like to convert the following markups(the outer bracket mean they are grouped as one tag: [ [Contacts] * Contact #1 * Contact #2 * Contact #3 [Friend Requests] * Jose ]...

What is the best way to fetch/render one-to-many relationships?

Hi, I have 2 models which look like that: class Entry(models.Model): user = models.ForeignKey(User) dataname = models.TextField() datadesc = models.TextField() timestamp = models.DateTimeField(auto_now=True) class EntryFile(models.Model): entry = models.ForeignKey(Entry) datafile = models.FileField(upload_to="uploads/%Y/%m/%d/...

Can I pickle upload file from a django form? I mean a InMemoryUploadedFile

I have a django form where I have a FileField which accepts user's resume. I am gonna convert the resume to a html document LATER. So I thought of pickling the original document right away and store in it a db colum and later unpickle it and convert it. Is that possible? ...

Django: Order a model by a many-to-many field

I am writing a Django application that has a model for People, and I have hit a snag. I am assigning Role objects to people using a Many-To-Many relationship - where Roles have a name and a weight. I wish to order my list of people by their heaviest role's weight. If I do People.objects.order_by('-roles__weight'), then I get duplicates w...

Django : Setting a generic (content_type) field with a real object sets it to None

Update 3 (Read This First) : Yes, this was caused by the object "profile" not having been saved. For those getting the same symptoms, the moral is "If a ForeignKey field seems to be getting set to None when you assign a real object to it, it's probably because that other objects hasn't been saved." Even if you are 100% sure that it wa...

Are there any new ruby on rails versus django articles?

I'm trying to decide between the two. I don't know ruby or python very well. I found some articles on SO. Are there any recommended sites? Googling only shows one or two. Thank you. ...

Prepopulate Django (non-Model) Form

I'm trying to prepopulate the data in my django form based on some information, but NOT using ModelForm, so I can't just set the instance. This seems like it should be really easy, but for some reason I can't find any documentation telling me how to do this. This is my form: class MyForm(forms.Form): charfield1 = forms.CharField(max...

Keep code from running during syncdb

hello again! I have some code that throws causes syncdb to throw an error (because it tries to access the model before the tables are created). Is there a way to keep the code from running on syncdb? something like: if not syncdb: run_some_code() Thanks :) edit: PS - I thought about using the post_init signal... for the code th...

Django 1.1 beta 1 - Flatpages Error, Debug = False, with 404.html

The Django flatpages app has a well-known and oft-discussed-on-the-web bug related to a missing 404.html "Page Not Found" template in your project's templates directory. If you have DEBUG = False in your settings.py file, and you're missing the 404.html file, flatpages will generate a 500 server error instead of loading the flatpage beca...

Use Django ORM as standalone

Possible Duplicates: Use only some parts of Django? Using only the DB part of Django I want to use the Django ORM as standalone. Despite an hour of searching Google, I'm still left with several questions: Does it require me to set up my Python project with a setting.py, /myApp/ directory, and modules.py file? Can I create a ne...