Designing django projects.

2009-10-05 Thread nbv4
I am just about ready to launch my django project that I've been working on for the past couple months. One of the things I wanted to do was have an actual graphic designer do it, so it doesn't look like a programmer designed the site, if you know what I mean. First off, my site is free, so I can

retrieving models without importing

2009-09-09 Thread nbv4
I remember reading about away to use django models without importing, but google fails me. I want to create a ForeignKey relation to another model, but I can't import it because that will call an endless loop of imports. I know about doing: field = models.ForeignKey("app.Model") but theres a bu

user disappearing when saved

2009-08-31 Thread nbv4
(Pdb) f0 (Pdb) f0.cleaned_data {'ipc': False, 'xc': 0, 'app': 0, 'pic': 0, 'cfi_checkride': False, 'dual_r': 0, 'date': datetime.date(2009, 9, 5), 'dual_g': 0, 'total': 5.5996, 'id': None, 'sic': 0, 'night_l': 0, 'holding': False, 'act_inst': 0, 'pilot_checkride': False, 'solo': 0, 'f

How do you remove fields from a subclassed form?

2009-08-30 Thread nbv4
class MyForm(ModelForm): field1 = CustomField(custom_option="sdsdsd") field2 = # ... # class Meta: class AnotherForm(MyForm): --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" gr

Creating a custom widget

2009-08-28 Thread nbv4
I have a Flight model which has a foreignkey field that relates to a route object. I created a custom field to go with my FlightForm that allows me to enter a simple string, which is then, via the clean() method, constructed into a Route object that is attached to the flight. This works fine, but

django-tagging not working in 1.1?

2009-08-11 Thread nbv4
I'm having trouble getting my tagged modles registered in 1.1 When I have "tagging.register(MyModel)" at the bottom, I get this error when I try to add a new instance of that model in the admin: "null value in column "object_id" violates not-null constraint" full traceback:

Slugs, why would you ever need to store one in the database?

2009-07-23 Thread nbv4
I'm looking into adding prettier URLs into my site with the help of slugs. I've never done something like this before, so I'm doing a lot of reading and am having trouble "getting" slugs. When creating URLs, couldn't you just do do something like "example.com/45/slug-goes- here"? Then have the vie

inlineformset delete on empty revisited

2009-07-10 Thread nbv4
http://pastebin.com/f40a3bde9 I found this little snippet on this group and am trying to get it to work on my model, but no luck. I'm using the code pretty much as-is except for two small changes, which are noted by a code comment. I can create new instances of my model using this formset, bit I

why doesn't the "with" template tag transverse blocks?

2009-06-23 Thread nbv4
I'm trying to set up a template for all my forms, but I'm having trouble using the {% with %} block: {% extends "base_form.html" %} {% with form.instance as object %} {% block title%} {{object.title}} <- not displayed :( {% endblock %} {% block body %} {% with form.instance as object %}

Re: geodjango: find all points from a database, bound by a polygon

2009-05-28 Thread nbv4
OMG wow that worked. Thanks a ton. On May 28, 6:44 pm, Ariel Nunez wrote: > > >>> from django.contrib.gis.gdal.envelope import Envelope > > >>> W = 39.9; N = -82.9; E=40.4; S=-82.2 > >  >>> bounds = Envelope((N, W, S, E, )) > > > >>> Base.objects.filter(location__intersects=bounds.wkt) > > Then

Re: geodjango: find all points from a database, bound by a polygon

2009-05-28 Thread nbv4
On May 28, 5:52 pm, Ariel Nunez wrote: > On Thu, May 28, 2009 at 4:12 PM, nbv4 wrote: > > > I have this model: > > > > from django.contrib.gis.db import models > > > class Base(models.Model): > >        identifier    

geodjango: find all points from a database, bound by a polygon

2009-05-28 Thread nbv4
I have this model: from django.contrib.gis.db import models class Base(models.Model): identifier = models.CharField(max_length=8, primary_key=True) local = models.CharField(max_length=8) iata= models.Cha

modelformset.forms.instance in a template

2009-05-27 Thread nbv4
View: def edit_operation(request, op_id): from forms import OpBaseForm from django.forms.models import modelformset_factory OpBaseFormSet = modelformset_factory(OpBase, form=OpBaseForm) op = Operation.objects.get(pk=op_id) formset = OpBaseFormSet(queryset=op.opbase_set.all())

Re: pluggable export to csv application

2009-05-27 Thread nbv4
On May 27, 1:29 pm, Nagy Viktor wrote: > Hi, > > I've put together a nifty export to csv application. You can check it out > athttps://launchpad.net/django-export-csv > > To get the code immediately just run: bzr branch lp:django-export-csv > an overview file and tests are included as well > > I

Re: why no modelformset from a modelform?

2009-05-27 Thread nbv4
well I'll be damned. I didn't see it here: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ So I assumed it couldn't do it... On May 27, 5:31 am, Daniel Roseman wrote: > On May 27, 9:55 am, nbv4 wrote: > > > I have a model which has about 4 field

why no modelformset from a modelform?

2009-05-27 Thread nbv4
I have a model which has about 4 fields. One of those fields is a foreign key to another model which has over 40,000 objects in the database. When I create a 'stock' ModelForm of this model, and display it in a template, it wants to create a with 40,000 items. I have created a custom ModelForm fo

mass entering data into django: ignoring errors

2009-05-25 Thread nbv4
I have about 42,000 lines in a database that I need imported into my Django database. I made a PHP script that outputs the data like o: Base.objects.get_or_create(identifier="92NC", local="92NC", type=5, elevation="1178", iata="", name="Grace Hospital Heliport",country="United States", region="No

2 seperate projects, or 2 seperate apps?

2009-05-22 Thread nbv4
I am currently working on two different websites in django. They will each be on their own domain when finished, and they will both have their own auth models (to use both sites, you need an account on each site). With that said, one of the sites will use data from the other one, and there will be

Re: OneToOneField, and inlines

2009-05-10 Thread nbv4
On May 10, 4:03 pm, Tom von Schwerdtner wrote: > Greetings folks, I've been wrestling with this and I really don't know > what I'm not doing right, so here is where I am: > > In basic pseudocode, I have: > > models.py: > --- > class Address(models.Model): >     ... ( street, city, e

inline within an inline -OR- __unicode__ for intermediary models

2009-05-10 Thread nbv4
I have one model that looks like this: class Position(models.Model): base = models.ManyToManyField("Base", through="PosBase", blank=True) [...] class PosBase(models.Model): position = models.ForeignKey("Position") base = models.ForeignKey("Base") class Base(models.Model): n

admin inlines saving empty objects

2009-05-06 Thread nbv4
I have an admin page set up where I have two inlines for this one model I have. Both inlines have extra=3 so theres three instances per inline. One of the inlines behaves badly by saving all three objects, even if two of them are completely empty. The other inline behaves nicely by only saving the

Re: ManyToMany with a "through" attribute in the admin profile

2009-05-04 Thread nbv4
On May 4, 12:03 am, George Song wrote: > On 5/3/2009 8:17 PM, nbv4 wrote: > > > > > On May 3, 3:51 pm, Ramiro Morales wrote: > >> On Sun, May 3, 2009 at 4:26 PM, nbv4 wrote: > > >>> Everything is fine and dandy, except for when I want to use the a

Re: ManyToMany with a "through" attribute in the admin profile

2009-05-03 Thread nbv4
On May 3, 3:51 pm, Ramiro Morales wrote: > On Sun, May 3, 2009 at 4:26 PM, nbv4 wrote: > > > Everything is fine and dandy, except for when I want to use the admin > > interface to create a new route. All I see is a dropdown for the > > "often" field. I have to

ManyToMany with a "through" attribute in the admin profile

2009-05-03 Thread nbv4
I have a few models that looks like this: - class Route(models.Model): points = models.ManyToManyField(Base, through="RouteBase") often = models.IntegerField(choices=ROUTE_OFTEN, default=0) class RouteBase(models.Model): point = models.ForeignKey("Base") route = models.Forei

Re: "DeprecationWarning: the sets module is deprecated"

2009-05-01 Thread nbv4
ettings.py file. Whoops :0 On May 1, 6:08 pm, Malcolm Tredinnick wrote: > On Fri, 2009-05-01 at 14:59 -0700, nbv4 wrote: > > Whenever I run the syncdb command, I get this error: > > > ch...@chris-desktop:~/Websites/jobmap$ python manage.py syncdb > > /var/lib/python-s

"DeprecationWarning: the sets module is deprecated"

2009-05-01 Thread nbv4
Whenever I run the syncdb command, I get this error: ch...@chris-desktop:~/Websites/jobmap$ python manage.py syncdb /var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet I'm using Python 2.6 on Ununtu 9.04. I s

django-tagging help

2009-01-06 Thread nbv4
I have django-tagging installed and working fine. I have a model called Plane, which has a few hundred objects in the database, almost all of them with at least one tag. The tagging_tag, and the tagging_taggeditem table in my database looks fine. All the tags are listed there correctly. When I loo

swapping out request.user in views

2009-01-01 Thread nbv4
I have a webapp that is accessed by the following urls (among others): example.com/foobar-page-23 example.com/preferences example.com/barfoo etc. When these URL's are access, the page is displayed using data from the user who is logged in via request.user. I also want it so the user can link o

non-fields being inherited by ModelForm

2008-12-22 Thread nbv4
I have a model which is defines kind of like this: MyModel(models.Model) field1 = models.BooleanField() field2 = models.BooleanField() field_num = "1" And then I have a form thats pretty much this: MyModelForm(models.ModelForm) class meta model = MyModel I want to be ab

Re: custom widgets

2008-12-19 Thread nbv4
On Dec 19, 3:34 pm, Daniel Roseman wrote: > On Dec 19, 8:11 pm, nbv4 wrote: > > > I have a model with a field called date_format. That field is an > > integer value from 1 to 9 corresponding to "D m-j-y", "m-d-Y", etc. I > > have the model defi

Re: Problem saving a User object to a profile

2008-12-19 Thread nbv4
On Dec 19, 3:15 pm, DragonSlayre wrote: > profile_form.user = user; > profile_form.save() The problem is that you can't assign fields in forms directly like this. The only way to input data into a form is when you initially create the form object ala: profile_form = ProfileForm(request.POST)

custom widgets

2008-12-19 Thread nbv4
I have a model with a field called date_format. That field is an integer value from 1 to 9 corresponding to "D m-j-y", "m-d-Y", etc. I have the model defined with a 'choices' set so the database can store the number, and a dropdown is created with the choices instead of just a textbox field. The p

Re: auth: get_profile(): create if it does not exist.

2008-12-17 Thread nbv4
On Dec 17, 5:00 am, Thomas Guettler wrote: > Hi, > > The method user.get_profile() fails, if the user has no profile. During > my custom login I > check if the user has a profile and create it if needed. > > But sometimes this fails: A new user gets created, but before his first > login someone e

how to do redirects with django?

2008-12-09 Thread nbv4
If the user goes to /foobar, I want it to redirect him to /foobar-page- XX, XX being the last page. I have a this in my urlconf" (r'^foobar/ $', 'project.main.views.foobar_no_page', ), (r'^foobar-page-(?P\d{1,4})/$', 'project.main.views.foobar', ), foobar() in my views in my main function, fooba

Re: Turning all zero's to blank strings in a model.

2008-11-26 Thread nbv4
On Nov 26, 9:06 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-11-26 at 19:50 -0800, nbv4 wrote: > > I'm new to django, and I'm having a problem setting up a model. > > > I have a model which has about 12 decimal fields and two integer >

Turning all zero's to blank strings in a model.

2008-11-26 Thread nbv4
I'm new to django, and I'm having a problem setting up a model. I have a model which has about 12 decimal fields and two integer fields. Each field, when displayed, will always be blank if the value is zero. In other words, "0" or "0.0" will never be displayed, either when the object is outputted