django

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

Dynamic Loading of Modules then using "from x import *" on loaded module

I have some django apps which are versioned by app name. appv1 appv2 The models.py in the apps are slightly different based on the version, but have the same model names. I'm attempting to load the models dynamically into the current namespace. So I've made a function that attempts to get the module and return it: def get_models_modu...

Dealing with timezones in Django

I'm trying to deal with timezone information in Django. I tried doing something like: results = Competitor.objects.raw("SELECT official_start AT TIME ZONE 'UTC', official_finish AT TIME ZONE 'UTC' FROM competitor WHERE race_id=1") Thinking that this way I would know that the timezone was UTC but say I store a time in the database that...

Select a COUNT using Django model?

Does anyone know if there's a way to just select the number of rows matching a query in Django? I have a search I've written that splits results into sets of 40, but I'd like to display the total number of results as well. I could to something like len(Model.objects.filter(name__icontains=search)), but it seems like that would be grossly...

How do I test whether a Django response was generated by a particular view?

Hi, In writing unit tests for Django, how would I test whether a particular view was used in rendering a URL? I was hoping there would exist TestCase.assertViewUsed, but I can't see it. Thanks. ...

different map icon for each user on single google map, multiple markers colours on single map

hi i am new to google maps api. i have a social app that diasplays the registerd user on a google map. App is based on Django. I have a little snippet to display the google maps. here is the code. <html style="height:100%;"> <head> <title>HOtNet MAP</title> <script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;"...

Using custom sql in Django

Is there a way to run a custum SQL statement in Django? I have some timestamp fields in my database that have timezone information. Normally you could just enter the time in a format like: 2010-7-30 15:11:22 EDT and in my case postgresql will figure it out. But in Django it treats timestamps as Datetimes which don't store timezone inform...

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

How to get rid of spacing in SimpleDocTemplate(). Python. ReportLab

Do someone know if it possible to delete default spancing when i'm making PDF document with SimpleDocTemplate(). I want it to print from corner to corner. response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=somefilename.pdf' # Our container for 'Flowable' objects ...

How do I run a django TestCase manually / against other database?

I have some methods written into a django.test.TestCase object that I'd like to run from the manage.py shell on my real database. But when I try to instantiate the TestCase object to run the test method, I get this error: ValueError: no such test method in <class 'track.tests.MentionTests'>: runTest Is there a way to instantiate the...

How do I delete an object in a django relation (While keeping all related objects)?

I have the following model: One name (Char) Many one (ForeignKey,blank=True,null=True) title (Char) I want to delete a One instance and all related objects should loose their relation to the One instance. At the moment my code looks like this: one=One.objects.get(<some criterion>) more=Many.objects.filter(one=one) for m ...

django send_mail get result

How can i get django send_mail result of email send. I run it local, i do send_mail to my email, and it return True, but letter not sended (because i have not any smtp set). But result is True. How to get real result? ...

Why is my Django installation delivering an empty HTTP response?

Final Update: There was a stray LoadModule python_module modules/mod_python.so that conflicted with mod_wsgi. Removing that LoadModule made everything work again. I am setting up a production server with Django and following along with the Django tutorial, yet receiving a blank page (or, as Chrome likes to report, Error 324 (net::ERR_...

Self Contained Pinax Project

I cloned a basic project. I was wondering which files do i have to copy so it becomes a completely self-contained project? I am referring to the css files, the templates, other apps? Also, where will these files be located. ...

django clean_field that references other fields

Hi all, I have a situation where a user can click a check box field, "field_enable", on an html form and a nice jQuery operation will display another field, "fielda", for the user to enter more data in. When "field_enable" is checked, I want to require the user to also fill out "fielda". When "field_enable" is unchecked, the user shoul...

jQuery not accessing DOM elements loaded via .load()

Hi all, I've read through some of the other posts and followed their suggested advice but to no avail. My function is called via an onclick event embedded within an element. Everything works fine. The data loads, but my focus event handler does not. "d-category" is a loaded element class. It does have multiple occurrences within the loa...

Django object extension / one to one relationship issues

Howdy. I'm working on migrating an internal system to Django and have run into a few wrinkles. Intro Our current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc. Base Objects So I have two base objects/models: JournalEntry JournalEntryItems defined as follows: ...

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

Mac ports Mysql install

I completed my install on Leopard with Mac Ports. I also installed Mysqld via Mac Ports for use with python. I set the password for mysql on mysql start. Everything seemed to be fine except when I invoke mysql-start from the command line now I get this: mysql-start ***Password: Starting MySQL . SUCCESS! demetrius-fords-macbook-pro-17:~ ...

setting up mysql on Mac

I first installed Macports so it would be easier. Then installed mysql5,mysql5-server and py26-mysql. Everything went ok. When I typed: which mysql5 it returns `/opt/local/bin/mysql5 But when i try to enter the server: mysql5, an error is generated: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var...