Tuesday, May 31, 2011

django-schedule + location model

Hi all,

I need to make a scheduling app and have found django-schedule:
https://github.com/bartekgorny/django-schedule

Not sure if it is the best choice, as the author seems to have
disappeared, but the others I'd found looked too simplistic.

I've installed the demo, and got it working. However I'm new to
Django, so would appreciate if anyone could give me some pointers on
the best way to add a Location model to it. I've got a few things
working, but not sure how to proceed from here.

Is it ok to modify the third party app, or should I reference/subclass
it from my own somehow?

Also, in the schedule app there are Events and on-the-fly Occurrences
(the actual events which don't have a table). I'm not sure where to
put the ManyToMany relationship to physical Location(s) in this
situation.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Does django 1.3 has a ubuntu deb package released!

I used:

sudo apt-get install python-pip
sudo pip install django


On Apr 29, 7:29 pm, Korobase <boyee...@gmail.com> wrote:
> Does django 1.3 has a ubuntu deb package released !
> I have googled but get none,Any one have done this?
> Thanks.
>
> --

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Chained forms

Hi!, 
I'm writing an admin action. 
This action needs to collect some information before execute the "final task".
In order to collect this information the user should fill 3 consecutive forms, (once they submitted one, another is rendered). 

My question is, 
How can I store the form fields state submitted on each form, and retrieve this fields states on the final form, before execute the 'final task'?

Thanks!
--
Marc

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to I create download link of some file using django

you are welcome!

> I have another question here. It seems that django.contrib.staticfiles
> can be used to handle some static files during the 'debug' mode while
> using the embedded 'runserver' from django. However, would it be
> possible if I just develop my website using the system's Apache and
> not using the django.contrib.staticfiles?

Of course and this is even better, because this is how the setup should be on real server.

You have to configure Apache to serve for example everything under http://mydomain.com/static/ as a simple file without talking to django at all. The static stuff is good for static files like CSS and JavaScript.

BTW: although this goes beyond the question I just want to mention it for completeness.

On the other hand the {{MEDIA_URL }} and MEDIA_ROOT is more for server/user generated files. You can still have Apache serve the file after authorizing it against Django. The keyword here is: x-sendfile

http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files

What you were doing with open the file probably only makes sense if you need to process the contents of the file in any way.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Learning Django: Approach / Advice / Resources

You guys are spectacular! Thanks! I'll give these replies a few
reads and just keep plugging along. I'm going to sort of circle back
and see if it wouldn't be a good idea to restart my project with a
fresh set of eyes now that I've spent a bit of time with Django.

Derek,

The test cookie thing is -- as I understand it -- you place a test
cookie, then check if it's there. It's basically a check to see if
the browser accepts cookies. I'm just not entirely sure when I should
and shouldn't make the check when using parts of the built-in auth
moduel. I guess if I'm using the login view, it's will test for me.
I sort of started with the whole auth system, then backed out of using
the form and the view just to learn how it works on a basic level.
And in browsing the code, I saw the test cookie functions and did some
research.

Thanks again!

Robin

On May 31, 8:07 am, Derek <gamesb...@gmail.com> wrote:
> On May 30, 9:30 pm, Robin <robin.sa...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > A little while ago, I was approached about building a basic web site
> > for a small store.  The requirements were pretty typical and read like
> > a menu of web development tutorials.  This was to be a data driven
> > site that any decent web developer could build.  I, however, am not a
> > web developer, decent or otherwise.  So, I turned the assignment down
> > and decided it's time I looked into learning something about web
> > development.
>
> > I looked at everything from ASP to Java to PHP and even the likes of
> > Drupal and Joomla.  I liked the ideas and patterns behind Django as a
> > framework ( MVC = :) ) and Python as a language.  The combination
> > seemed like perfect middle ground to me.  Things were going well as I
> > worked through the tutorial and explored the documentation to dig
> > deeper into core Django topics.  Where am I today?
>
> > I'm struggling a bit with Django, to be honest.  Or maybe I'm
> > struggling with Python, I'm not completely certain which.  Maybe it's
> > because I'm trying to learn web development and Python at the same
> > time.  I'm certainly no genius, but I'm not a bonehead either...at
> > least my mother doesn't think so. ;)
>
> > The individual technical ideas are presented well and I can always
> > find enough information to learn more.  But Django as a whole feels
> > less cohesive.  Or maybe it's that Django sometimes feels...TOO
> > flexible?  There are certainly a lot of choices in terms of how much
> > Django to use and how much to roll yourself.  Guidance seems to be
> > offered on a per-module basis.  Maybe that's just how it is and I'm
> > looking for structure where there is none available.
>
> > I'm not sure what to override...when to call the super classes
> > corresponding method.  Do I have to concern myself with the test
> > cookie idea?  Should I name my URLs?  Is mixing positional and keyword
> > arguments OK?  Are generic views the best way, or just the quickest
> > way?
>
> > I guess it boils down to a concern over making poor choices and
> > learning bad habits.  If I'm going to spend any amount of time with
> > this web development hing, I want to do it right.  I'm also fighting
> > my urge to build everything myself.  Sure it would be plenty flexible,
> > but it would also take longer and wouldn't leverage the great work
> > done by all of Django's contributors.
>
> > So, what am I rattling on about then?
>
> > Judging by some of the posts I've read since joining the group, I'm
> > sure there are a bunch of folks who would appreciate some guidance
> > and / or best practices from the more experienced Django developers.
> > I understand everyone learns and progresses differently, but I would
> > really appreciate your take on things.
>
> > How much do you use built in Django functionality?  Are there
> > components you tend to avoid?  Do you use Django only for certain
> > types of projects?  Do you struggle with Python or Django?  Is the
> > source code a good place to spend some time?  Is your authentication
> > system home-grown?  Have you been bitten in the behind by using too
> > much Django?  Not enough?
>
> > I realize this is a lot to ask, but I think it's a good thing that we
> > help newer developers do things the right way.  I certainyl want to
> > become a contributing member of this group, but not until I won't give
> > bad advice and flat out wrong answers. ;)
>
> > I've gone through a good chunk of the Django Book online.  Is this a
> > good resource or do you have other recommendations?  There aren't all
> > that many books on Django, but there are a few.  Do any do a better
> > job than the others of guiding you to the best way to build web
> > sites / apps?  I sure wish there was a book that kept pace with the
> > changes and the miost recent version.  Is the fact that there isn't
> > much available a bad sign?
>
> > Just jump in and adjust as I learn my lessons?
>
> > Regards,
>
> > Robin
>
> Hi Robin
>
> Not sure I can address all your issues, so I will just pick up on a
> few...
>
> One thing from the start -> " If I'm going to spend any amount of time
> with this web development thing, I want to do it right."  You will -
> eventually.  Its often really hard to do it right first time because
> you do not have enough experience to know if you're making a mistake!
> Getting going, doing stuff and maybe putting out in public the parts
> you are most concerned/unsure about is the best way to get the
> experience...
>
> "struggling with Python"
>
> I cannot say that its essential to know Python in depth before
> starting web programming, but I would say it would be a huge help.
>
> Its not clear what programming experience you have. If none, then its
> worth starting with the basics of programming.  If you have some, then
> try and find a comparison between the language you used and Python
> (pref. written by a Python person).
>
> Some useful "getting started" tutorials:
> *http://docs.activestate.com/activepython/2.5/easytut/index.html
> *http://www.gidnetwork.com/b-26.html
>
> After reading and trying out what someone else has done, try and build
> stand-alone stuff in Python.  A simple use case is accessing and
> processing Excel spreadsheets using xlwt and xlrd.  If you ever have
> to do any data processing for third-parties, you're almost bound to
> use/re-use what you have done here.  Otherwise think of a common need
> from the area you work in.
>
> "struggling with Django"
>
> Django is meant to be comprehensive.  That's good if you want to be
> able to do anything, but bad if you're just getting started.  If I
> showed my old self from 2 years ago the code that I have written
> today, I'd be overwhelmed, no doubt.  Learning programming is
> incremental and experiential.  You learn code by writing; and improve
> code by writing more.  Remember (and this is easy to forget!!) that
> the entire source code of Django is open to you... take some time and
> read some of it - Python is designed to be a readable language.  If
> its too overwhelming, then try and look at the code of some of the
> apps that are out there (and there are lots!).  You'll see an entire
> "module" and start to get some idea of how it all hangs together.
> Then try it yourself; maybe start with something already there and
> make changes to it until it breaks - try and figure out why - fix it -
> and keep going.  Use the same basic concepts to try and build
> something new-ish yourself from scratch.  As you go along and get
> really stuck, post questions to the list (and please check first in
> the archives - many people experience similar problems).
>
> Q&A
>
> Q: How much do you use built in Django functionality?
> A: All the time!
>
> Q: Are there components you tend to avoid?
> A: None that come to mind; but I just use the ones I really need
> ("learn as you go").
>
> Q: Do you use Django only for certain types of projects?
> A: Its my primary web development framework; in my situation there is
> no need to use multiple ones (and probably not a good idea when you're
> just starting)
>
> Q: Do you struggle with Python or Django?
> A: Often - but that is when I *know* that I am learning
>
> Q: Is the source code a good place to spend some time?
> A: See above.
>
> Q: Is your authentication system home-grown?
> A: Nope; using 'auth' works for me
>
> Q: Have you been bitten in the behind by using too much Django?
> A: Not so far...
>
> Q: I sure wish there was a book that kept pace with the  changes and
> the most recent version.  Is the fact that there isn't much available
> a bad sign?
> A: Depends if you think the publishing industry is keeping up with the
> web programming industry ;)  I think you'll have to get one of the
> committers to answer that; but to be honest I would rather they fixed
> bugs and added features than wrote books (my 2c).  In the meantime,
> the online docs are readable, comprehensive and up-to-date.  Django
> has one of the most well-documented codebase of any open source
> project.
>
> Hope some of this helps - welcome to the community!
>
> Derek
>
> P.S. "Do I have to concern myself with the test  cookie idea?  I have
> no idea what this is... please enlighten me!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to create user on mobile app for Django site?

On May 31, 4:35 am, Ivo Brodien <i...@brodien.de> wrote:
> What is the correct way to do the following:
>
> 1) Mobile App from which a user can create a user/profile on the Django site
> 2) Allow authenticated users to create on the site and query personalized data from the site

My approach would be to:

1) Build a regular site using django-registration and django-profiles
to handle signups, passwords as usual.

2) Build an HTML mobile site off of that (you need one anyway, even if
you're going to have an app). There are lots of tutorials out there on
delivering mobile versions of content with Django.

3) Use something like Sencha or Phonegap to compile the mobile site as
iPhone and Android apps.

./s

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to I create download link of some file using django

Thanks for your help Ivo,

I have another question here. It seems that django.contrib.staticfiles
can be used to handle some static files during the 'debug' mode while
using the embedded 'runserver' from django. However, would it be
possible if I just develop my website using the system's Apache and
not using the django.contrib.staticfiles?

Kann

On May 31, 4:51 pm, Ivo Brodien <i...@brodien.de> wrote:
> > I am a bit confused about how to set the MEDIA_URL variable here.
> > Currently, I am testing the web using Django embedded webserver and
> > doesn't have a proper url yet. Should my MEDIA_URL be something
> > like...http://my_machine_name:8000/media/
>
> yes, but so in your template you do:
>
> > ### in the template ####
> > <a href="{{ MEDIA_URL }}{{ django_file.url }}>download</a>
>
> Your:> <a href="file:///{{ django_file.url }}>download</a>
>
> file:/// will only work on you machine, since file:/// is pointing to a local file

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Accessing request.user in formset validation

Hi Tom,

wow, perfect!!

A thousand thanks for your help and example code!
:-D

Best regards,
Carsten

--
Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
Learn more at http://www.cafu.de

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: admin site search field

I found one solutions:
field = models.OneToOneField("self")
Im now searching how have a search form instead of a combo box.

On 31 mayo, 10:10, podio <ven...@podiodeportes.com.ar> wrote:
> yes, that was that I copy and didn't select de ', so when I pasted I
> saw only the missing bracket.
>
> On 31 mayo, 04:07, delegb...@dudupay.com wrote:
>
>
>
>
>
>
>
> > First, you did enclose doc properly. You wrote 'doc instead of 'doc'.
> > Sort that first. I'm however not suggesting that is the solution.
> > Regards.
> > Sent from my BlackBerry wireless device from MTN
>
> > -----Original Message-----
> > From: podio <ven...@podiodeportes.com.ar>
>
> > Sender: django-users@googlegroups.com
> > Date: Mon, 30 May 2011 16:24:10
> > To: Django users<django-users@googlegroups.com>
> > Reply-To: django-users@googlegroups.com
> > Subject: admin site search field
>
> > Hi, I'm new and I'm trying to make an app that have a field, pointing
> > to a record of the same object class. How can a make django has a
> > search form and show the record of the class on a popup window likehttp://demoweb.cibernatural.com/admin/gestion/presupuesto/add/(user
> > and password demo:demo) but pointing to the same class
>
> > class afiliado(models.Model):
> >     def __unicode__(self):
> >         return self.nombre
> >     nombre = models.CharField("Nombre",max_length=200)
> >     fecha_nac  = models.DateField("Fecha Nacimiento")
> >     doc = models.CharField("Documento",max_length=20,blank =True)
> >     obra_social = models.ForeignKey(obra_sociale)
> >     caracter = models.ForeignKey(caractere)
> >     tipo = models.ForeignKey(tipo)
> >     titular = models.CharField(max_length=200) ------------> this
> > field
>
> > class AfiliadoAdmin(admin.ModelAdmin):
> >     fieldsets = [
> >         (None               ,{'fields':
> > ['nombre','fecha_nac','DOCN','Nacionalidad']}),
> >         ('Datos Generales'  ,{'fields':
> > ['obra_social','caracter','tipo',"titular",'Matricula','fecha_ing']}),
> >         ('Datos de contacto',{'fields':
> > ['Direccion',"CP","Ciudad","Provincia","Tel1","Tel2","Email"]}),
> >     ]
> >     list_display = ('nombre',"tipo")
> >     list_filter = ['Ciudad']
> >     search_fields = ['nombre','doc]
>
> > Thansk!
>
> > --
> > You received this message because you are subscribed to the Google Groups "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Does django 1.3 has a ubuntu deb package released!

You can always install the debian package from:

http://packages.debian.org/wheezy/python-django

which seems to work fine...

On Apr 30, 3:29 am, Korobase <boyee...@gmail.com> wrote:
> Does django 1.3 has a ubuntu deb package released !
> I have googled but get none,Any one have done this?
> Thanks.
>
> --

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: how to implement a data grid? (or populate inlineformset with initial data)

On Tuesday, 31 May 2011 15:20:11 UTC+1, snfctech wrote:
Thanks, Jayapal.

I was hoping there was a little less java/ more django way to do this
by utilizing a Django ModelForm or InlindeFormSet and rendering
partial views.

So am I missing the point of InlineFormSets?  Can these not be
populated with data so they can be used to edit a set of existing
records?

Thanks.

Tony

No, you're not missing the point - that is exactly what model formsets are for. But you haven't read the documentation very closely: InlineFormsets are meant for editing only those elements that are related via ForeignKey to a specific object, so it is that related object that you pass to the formset via the `instance` parameter. The documentation shows this clearly: https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#inline-formsets

If you want to edit the elements of a queryset that aren't necessarily all related to the same object, you just use a standard ModelFormset, which does take a `queryset` argument - again, as shown in the docs: https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#using-a-custom-queryset
--
DR.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to I create download link of some file using django

> I am a bit confused about how to set the MEDIA_URL variable here.
> Currently, I am testing the web using Django embedded webserver and
> doesn't have a proper url yet. Should my MEDIA_URL be something
> like... http://my_machine_name:8000/media/


yes, but so in your template you do:

> ### in the template ####


> <a href="{{ MEDIA_URL }}{{ django_file.url }}>download</a>


Your:
> <a href="file:///{{ django_file.url }}>download</a>
file:/// will only work on you machine, since file:/// is pointing to a local file

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to I create download link of some file using django

Hi did you read this documentation about serving static files?

In generally you don't want serve files through django, but through your actual webserver (e.g. Apache, nginx, lighttpd...).

However during development you can make django serve them.

See: Serving static files in development

https://docs.djangoproject.com/en/dev/howto/static-files/

Since it can become a bit cumbersome to define this URL pattern, Django ships with a small URL helper function static() that takes as parameters the prefix such as MEDIA_URL and a dotted path to a view, such as 'django.views.static.serve'. Any other function parameter will be transparently passed to the view.
An example for serving MEDIA_URL ('/media/') during development:


from django.conf import settings
from django.conf.urls.static import static

urlpatterns = patterns('',


# ... the rest of your URLconf goes here ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

cheers


On May 31, 2011, at 4:24 PM, Kann wrote:

> Dear all,
>
> I am a bit confused about how to set the MEDIA_URL variable here.
> Currently, I am testing the web using Django embedded webserver and
> doesn't have a proper url yet. Should my MEDIA_URL be something
> like... http://my_machine_name:8000/media/
>
> Kann
>
> On May 26, 12:42 pm, Boštjan Mejak <bostjan.me...@gmail.com> wrote:
>> Fix some_file = open('bla/bla/bla/', "rw") to some_file =
>> open('bla/bla/bla/', "r")
>>
>> Fix that "rw" to just "r". You just want the user to read (a.k.a. get) the
>> file, not have write access to it.
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: how to implement a data grid? (or populate inlineformset with initial data)

On Tue, May 31, 2011 at 9:20 AM, snfctech <tschmidt@sacfoodcoop.com> wrote:
> I was hoping there was a little less java/ more django way to do this

i haven't seen any Java around Dojo toolkit

--
Javier

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to I create download link of some file using django

Dear all,

I am a bit confused about how to set the MEDIA_URL variable here.
Currently, I am testing the web using Django embedded webserver and
doesn't have a proper url yet. Should my MEDIA_URL be something
like... http://my_machine_name:8000/media/

Kann

On May 26, 12:42 pm, Boštjan Mejak <bostjan.me...@gmail.com> wrote:
> Fix   some_file  = open('bla/bla/bla/', "rw")    to    some_file  =
> open('bla/bla/bla/', "r")
>
> Fix that "rw" to just "r". You just want the user to read (a.k.a. get) the
> file, not have write access to it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: how to implement a data grid? (or populate inlineformset with initial data)

Thanks, Jayapal.

I was hoping there was a little less java/ more django way to do this
by utilizing a Django ModelForm or InlindeFormSet and rendering
partial views.

So am I missing the point of InlineFormSets? Can these not be
populated with data so they can be used to edit a set of existing
records?

Thanks.

Tony

On May 31, 12:03 am, jai_python <jayapa...@gmail.com> wrote:
> Hi,
>     Long back i had used Dojodatagrid, plz go through my bloghttp://jayapal-d.blogspot.com/2009/08/dojo-datagrid-with-editable-cel...
>
> I am sure that we can do with jquery.
>
> Lemme know if u required any help.
>
> Thanks,
> Jayapal
>
> On May 31, 6:39 am, snfctech <tschm...@sacfoodcoop.com> wrote:
>
> > I want to display a list of records that have some editable fields and
> > some readonly fields, as well as asynchronously add new records to the
> > list.  I thought the way to start would be with an InlineFormSet - but
> > I can't figure out how to populate my formset with initialdata.  E.g.
> > MyInlineFormset(queryset=myquery.all()) or
> > MyInlineFormset(data=myquery.vales()) doesn't do the trick.
>
> > Can someone steer me in the right direction?
>
> > Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: python code works in command line but not in django

On May 31, 4:06 pm, Kann <vearas...@gmail.com> wrote:
> I am just new to programming and not quite familiar with pdb. But I
> assume that this is what you are talking about:
>
> http://docs.python.org/library/pdb.html


Yes, that's it. This and the logging module are tools that are really
worth spending some time learning, as they will save you way more time
in the long run.

Note that there are similar tools for Java, if you ever need to trace
code execution in the Java program.

Also and while we're at it, you may want to at least check the return
code from the os.system code (or replace the call to os.system with
some subprocess function or method that allow you to catch and check
the stderr of the Java process).

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Learning Django: Approach / Advice / Resources

On May 30, 9:30 pm, Robin <robin.sa...@gmail.com> wrote:
> A little while ago, I was approached about building a basic web site
> for a small store.  The requirements were pretty typical and read like
> a menu of web development tutorials.  This was to be a data driven
> site that any decent web developer could build.  I, however, am not a
> web developer, decent or otherwise.  So, I turned the assignment down
> and decided it's time I looked into learning something about web
> development.
>
> I looked at everything from ASP to Java to PHP and even the likes of
> Drupal and Joomla.  I liked the ideas and patterns behind Django as a
> framework ( MVC = :) ) and Python as a language.  The combination
> seemed like perfect middle ground to me.  Things were going well as I
> worked through the tutorial and explored the documentation to dig
> deeper into core Django topics.  Where am I today?
>
> I'm struggling a bit with Django, to be honest.  Or maybe I'm
> struggling with Python, I'm not completely certain which.  Maybe it's
> because I'm trying to learn web development and Python at the same
> time.  I'm certainly no genius, but I'm not a bonehead either...at
> least my mother doesn't think so. ;)
>
> The individual technical ideas are presented well and I can always
> find enough information to learn more.  But Django as a whole feels
> less cohesive.  Or maybe it's that Django sometimes feels...TOO
> flexible?  There are certainly a lot of choices in terms of how much
> Django to use and how much to roll yourself.  Guidance seems to be
> offered on a per-module basis.  Maybe that's just how it is and I'm
> looking for structure where there is none available.
>
> I'm not sure what to override...when to call the super classes
> corresponding method.  Do I have to concern myself with the test
> cookie idea?  Should I name my URLs?  Is mixing positional and keyword
> arguments OK?  Are generic views the best way, or just the quickest
> way?
>
> I guess it boils down to a concern over making poor choices and
> learning bad habits.  If I'm going to spend any amount of time with
> this web development hing, I want to do it right.  I'm also fighting
> my urge to build everything myself.  Sure it would be plenty flexible,
> but it would also take longer and wouldn't leverage the great work
> done by all of Django's contributors.
>
> So, what am I rattling on about then?
>
> Judging by some of the posts I've read since joining the group, I'm
> sure there are a bunch of folks who would appreciate some guidance
> and / or best practices from the more experienced Django developers.
> I understand everyone learns and progresses differently, but I would
> really appreciate your take on things.
>
> How much do you use built in Django functionality?  Are there
> components you tend to avoid?  Do you use Django only for certain
> types of projects?  Do you struggle with Python or Django?  Is the
> source code a good place to spend some time?  Is your authentication
> system home-grown?  Have you been bitten in the behind by using too
> much Django?  Not enough?
>
> I realize this is a lot to ask, but I think it's a good thing that we
> help newer developers do things the right way.  I certainyl want to
> become a contributing member of this group, but not until I won't give
> bad advice and flat out wrong answers. ;)
>
> I've gone through a good chunk of the Django Book online.  Is this a
> good resource or do you have other recommendations?  There aren't all
> that many books on Django, but there are a few.  Do any do a better
> job than the others of guiding you to the best way to build web
> sites / apps?  I sure wish there was a book that kept pace with the
> changes and the miost recent version.  Is the fact that there isn't
> much available a bad sign?
>
> Just jump in and adjust as I learn my lessons?
>
> Regards,
>
> Robin


Hi Robin

Not sure I can address all your issues, so I will just pick up on a
few...

One thing from the start -> " If I'm going to spend any amount of time
with this web development thing, I want to do it right." You will -
eventually. Its often really hard to do it right first time because
you do not have enough experience to know if you're making a mistake!
Getting going, doing stuff and maybe putting out in public the parts
you are most concerned/unsure about is the best way to get the
experience...

"struggling with Python"

I cannot say that its essential to know Python in depth before
starting web programming, but I would say it would be a huge help.

Its not clear what programming experience you have. If none, then its
worth starting with the basics of programming. If you have some, then
try and find a comparison between the language you used and Python
(pref. written by a Python person).

Some useful "getting started" tutorials:
* http://docs.activestate.com/activepython/2.5/easytut/index.html
* http://www.gidnetwork.com/b-26.html

After reading and trying out what someone else has done, try and build
stand-alone stuff in Python. A simple use case is accessing and
processing Excel spreadsheets using xlwt and xlrd. If you ever have
to do any data processing for third-parties, you're almost bound to
use/re-use what you have done here. Otherwise think of a common need
from the area you work in.

"struggling with Django"

Django is meant to be comprehensive. That's good if you want to be
able to do anything, but bad if you're just getting started. If I
showed my old self from 2 years ago the code that I have written
today, I'd be overwhelmed, no doubt. Learning programming is
incremental and experiential. You learn code by writing; and improve
code by writing more. Remember (and this is easy to forget!!) that
the entire source code of Django is open to you... take some time and
read some of it - Python is designed to be a readable language. If
its too overwhelming, then try and look at the code of some of the
apps that are out there (and there are lots!). You'll see an entire
"module" and start to get some idea of how it all hangs together.
Then try it yourself; maybe start with something already there and
make changes to it until it breaks - try and figure out why - fix it -
and keep going. Use the same basic concepts to try and build
something new-ish yourself from scratch. As you go along and get
really stuck, post questions to the list (and please check first in
the archives - many people experience similar problems).

Q&A

Q: How much do you use built in Django functionality?
A: All the time!

Q: Are there components you tend to avoid?
A: None that come to mind; but I just use the ones I really need
("learn as you go").

Q: Do you use Django only for certain types of projects?
A: Its my primary web development framework; in my situation there is
no need to use multiple ones (and probably not a good idea when you're
just starting)

Q: Do you struggle with Python or Django?
A: Often - but that is when I *know* that I am learning

Q: Is the source code a good place to spend some time?
A: See above.

Q: Is your authentication system home-grown?
A: Nope; using 'auth' works for me

Q: Have you been bitten in the behind by using too much Django?
A: Not so far...

Q: I sure wish there was a book that kept pace with the changes and
the most recent version. Is the fact that there isn't much available
a bad sign?
A: Depends if you think the publishing industry is keeping up with the
web programming industry ;) I think you'll have to get one of the
committers to answer that; but to be honest I would rather they fixed
bugs and added features than wrote books (my 2c). In the meantime,
the online docs are readable, comprehensive and up-to-date. Django
has one of the most well-documented codebase of any open source
project.


Hope some of this helps - welcome to the community!

Derek

P.S. "Do I have to concern myself with the test cookie idea? I have
no idea what this is... please enlighten me!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: python code works in command line but not in django

I am just new to programming and not quite familiar with pdb. But I
assume that this is what you are talking about:

http://docs.python.org/library/pdb.html

Perhaps, I will look into it.

Thanks for your suggestions. :)

Kann

On May 31, 3:13 pm, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On May 31, 12:25 pm, Kann <vearas...@gmail.com> wrote:
>
> > Hi Bruno,
>
> > I tested with both system's python shell and the "manage.py shell",
> > and both of them also worked. The PNG file was created properly.
>
> Ok.
>
> > I also check the path returned from os.path.abspath() and both of them
> > are ok as well.
>
> Ok.
>
> > Now I am testing using the Django embedded development server.
>
> Well... If it works using django shell and not using the embedded
> server, you'll have to step-debug your code (you know how to use
> pdb ?).
>
> If it works using the embedded server and fail using Apache or another
> front-end web server, then it's most probably some ENV / permission
> problem.
>
> HTH

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Accessing request.user in formset validation

On Tue, May 31, 2011 at 2:21 PM, Carsten Fuchs <carsten.fuchs@cafu.de> wrote:
> Hi all,
>
> in some of my forms and formsets I need access to request.user in form
> validation.
>
> With an individual form, I pass request.user as a parameter to the
> constructor, using code like this:
>
> class ErfasseZeitraumForm(forms.Form):
>    von    = forms.DateField(widget=AdminDateWidget())
>    bis    = forms.DateField(widget=AdminDateWidget())
>
>    def __init__(self, User, *args, **kwargs):
>        super(ErfasseZeitraumForm, self).__init__(*args, **kwargs)
>        self.User = User
>
>
> How can I achieve the same for entire formsets?
>
> I'm still quite new to Python, and I'm unsure what to override where to make
> the formset factory pass the request.user to all form constructors, or even
> if that is the "best" and canonical way to this?
>
> Thank you very much!
>
> Best regards,
> Carsten

You need to define a class which inherits from BaseFormSet class,
override the __init__ method to accept the user as an argument,
override the _construct_form() method to add the additional user
argument to the form kwargs.
Then, define a form class which accepts the user argument in its
__init__ method.
Finally, specify to Django to use these forms by passing them as the
form and formset arguments to formset_factory or modelformset_factory
- the same technique applies to both.

Eg for some LogEntry model:

from django.forms.models import ModelForm, BaseModelFormSet,\
modelformset_factory
from models import LogEntry

class LogEntryBaseFormSet(BaseModelFormSet):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(LogEntryBaseFormSet, self).__init__(*args, **kwargs)
def _construct_form(self, i, **kwargs):
kwargs['user'] = self.user
return super(LogEntryBaseFormSet, self)._construct_form(i, **kwargs)

class LogEntryForm(ModelForm):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(LogEntryForm, self).__init__(*args, **kwargs)
def clean(self):
# use self.user
return self.cleaned_data

LogEntryFormSet = modelformset_factory(LogEntry, form=LogEntryForm,
formset=LogEntryBaseFormSet, extra=3, can_delete=True)


Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Is there an HTML editor that's Django-aware

I would suggest a section that all that newbies can visit on the website, with links to various text editors so that they can make their own decisions depending on their own personal preference etc.

Cheers

JP De Villiers

On Tue, May 31, 2011 at 3:26 PM, Tom Evans <tevans.uk@googlemail.com> wrote:
On Mon, May 30, 2011 at 2:41 PM, Jacob Kaplan-Moss <jacob@jacobian.org> wrote:
> On Monday, May 30, 2011, BobX <r_l_cross@dechro.co.uk> wrote:
>> If anyone from the Django Project itself is listening then can I (very
>> humbly) suggest that some editor recommendations would make a real
>> fine addition to the info on the site (useful to n00b's like me
>> anyway).
>
> That's a good idea - thanks!
>
> Where do you think such information should live? That is, at what
> point in your process of learning Django would information about
> editors have been helpful? Somewhere in the tutorial, or after?
> Before?
>
> Thanks,
>
> Jacob
>

The wording on this should be very careful. The default answer to
'what editor should I use to develop with Django' should be 'the one
that you know how to use and are comfortable using'.

We shouldn't be suggesting that there are a couple of 'correct'
choices, but perhaps providing hints and tips on how to fully use
certain popular editors with Django, eg how to correctly enable syntax
highlighting for django templates in various editors.

We definitely should not be trying to answer the question 'what is the
best editor for Django', or in any way try to suggest to noobies that
they must/should learn a new editor as well as learning Django.

The idea that because someone is new to Django means that they must
also be new to typing to text into a file and need our help to guide
them is somewhat patronizing.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Is there an HTML editor that's Django-aware

On Mon, May 30, 2011 at 2:41 PM, Jacob Kaplan-Moss <jacob@jacobian.org> wrote:
> On Monday, May 30, 2011, BobX <r_l_cross@dechro.co.uk> wrote:
>> If anyone from the Django Project itself is listening then can I (very
>> humbly) suggest that some editor recommendations would make a real
>> fine addition to the info on the site (useful to n00b's like me
>> anyway).
>
> That's a good idea - thanks!
>
> Where do you think such information should live? That is, at what
> point in your process of learning Django would information about
> editors have been helpful? Somewhere in the tutorial, or after?
> Before?
>
> Thanks,
>
> Jacob
>

The wording on this should be very careful. The default answer to
'what editor should I use to develop with Django' should be 'the one
that you know how to use and are comfortable using'.

We shouldn't be suggesting that there are a couple of 'correct'
choices, but perhaps providing hints and tips on how to fully use
certain popular editors with Django, eg how to correctly enable syntax
highlighting for django templates in various editors.

We definitely should not be trying to answer the question 'what is the
best editor for Django', or in any way try to suggest to noobies that
they must/should learn a new editor as well as learning Django.

The idea that because someone is new to Django means that they must
also be new to typing to text into a file and need our help to guide
them is somewhat patronizing.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Accessing request.user in formset validation

Hi all,

in some of my forms and formsets I need access to request.user in form
validation.

With an individual form, I pass request.user as a parameter to the
constructor, using code like this:

class ErfasseZeitraumForm(forms.Form):
von = forms.DateField(widget=AdminDateWidget())
bis = forms.DateField(widget=AdminDateWidget())

def __init__(self, User, *args, **kwargs):
super(ErfasseZeitraumForm, self).__init__(*args, **kwargs)
self.User = User


How can I achieve the same for entire formsets?

I'm still quite new to Python, and I'm unsure what to override where to
make the formset factory pass the request.user to all form constructors,
or even if that is the "best" and canonical way to this?

Thank you very much!

Best regards,
Carsten

--
Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
Learn more at http://www.cafu.de

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: BadValueError: Property title is required

On May 31, 11:45 am, "michal.bulla" <michal.bu...@gmail.com> wrote:
> Hello,
>
> I'm trying to create simple method to create category. I set the model
> category:
>
> class Category(db.Model):
>  title = db.StringProperty(required=True)
>  clashes_count = db.IntegerProperty(default=0)


Are you sure you posted on the right newsgroup ?-)

You're obviously not using Django's ORM.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: python code works in command line but not in django

On May 31, 12:25 pm, Kann <vearas...@gmail.com> wrote:
> Hi Bruno,
>
> I tested with both system's python shell and the "manage.py shell",
> and both of them also worked. The PNG file was created properly.

Ok.

> I also check the path returned from os.path.abspath() and both of them
> are ok as well.

Ok.

> Now I am testing using the Django embedded development server.

Well... If it works using django shell and not using the embedded
server, you'll have to step-debug your code (you know how to use
pdb ?).

If it works using the embedded server and fail using Apache or another
front-end web server, then it's most probably some ENV / permission
problem.


HTH

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: admin site search field

yes, that was that I copy and didn't select de ', so when I pasted I
saw only the missing bracket.


On 31 mayo, 04:07, delegb...@dudupay.com wrote:
> First, you did enclose doc properly. You wrote 'doc instead of 'doc'.
> Sort that first. I'm however not suggesting that is the solution.
> Regards.
> Sent from my BlackBerry wireless device from MTN
>
>
>
>
>
>
>
> -----Original Message-----
> From: podio <ven...@podiodeportes.com.ar>
>
> Sender: django-users@googlegroups.com
> Date: Mon, 30 May 2011 16:24:10
> To: Django users<django-users@googlegroups.com>
> Reply-To: django-users@googlegroups.com
> Subject: admin site search field
>
> Hi, I'm new and I'm trying to make an app that have a field, pointing
> to a record of the same object class. How can a make django has a
> search form and show the record of the class on a popup window likehttp://demoweb.cibernatural.com/admin/gestion/presupuesto/add/(user
> and password demo:demo) but pointing to the same class
>
> class afiliado(models.Model):
>     def __unicode__(self):
>         return self.nombre
>     nombre = models.CharField("Nombre",max_length=200)
>     fecha_nac  = models.DateField("Fecha Nacimiento")
>     doc = models.CharField("Documento",max_length=20,blank =True)
>     obra_social = models.ForeignKey(obra_sociale)
>     caracter = models.ForeignKey(caractere)
>     tipo = models.ForeignKey(tipo)
>     titular = models.CharField(max_length=200) ------------> this
> field
>
> class AfiliadoAdmin(admin.ModelAdmin):
>     fieldsets = [
>         (None               ,{'fields':
> ['nombre','fecha_nac','DOCN','Nacionalidad']}),
>         ('Datos Generales'  ,{'fields':
> ['obra_social','caracter','tipo',"titular",'Matricula','fecha_ing']}),
>         ('Datos de contacto',{'fields':
> ['Direccion',"CP","Ciudad","Provincia","Tel1","Tel2","Email"]}),
>     ]
>     list_display = ('nombre',"tipo")
>     list_filter = ['Ciudad']
>     search_fields = ['nombre','doc]
>
> Thansk!
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Why self-defined session_key got changed when save in DB?

On Sat, May 28, 2011 at 4:00 AM, Jimmy <jimmy.don.know@gmail.com> wrote:
> Hi,
>
> I have following code to set self-defined session_key:
>
>>>> from django.contrib.sessions.backends.db import SessionStore
>>>> from django.contrib.sessions.models import Session
>>>> a = SessionStore(session_key="fwefwejfo3j20jf02jnfweojfeo")
>>>> a.save()
>>>> a.session_key
> 'a6e020a64789b5644e923c85b80a1d0b'
>
> Why the session_key got changed after saved in DB? Where is my defined
> session_key?
>

This is not a bug, it is by design. The session app is protecting you
from session fixation attacks.

If you try to use a session with a specified key, and no session with
that key exists, django will cycle the session key to avoid a user
being caught by a session fixation attack, where a malicious user
attempts to get a valid user to log in using a known session key, and
then accesses their session.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

How to create user on mobile app for Django site?

What is the correct way to do the following:

1) Mobile App from which a user can create a user/profile on the Django site
2) Allow authenticated users to create on the site and query personalized data from the site

This is what I guess I have to do:

1) Create a REST API (probably with e.g. django-piston) on at the Django site for creation and authentication

How would I authenticate against the Django site?

When I use URL connections from the mobile app do I always have to send the credentials or can the Django site identify me by storing session cookies on the client just like as if the mobile app would be a browser?

Note: When I say mobile app I actually mean iPhone App for now, but there might be a Android version sometime in the future.

Thanks for any advice!


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Serving static file on Windows

Hi,

I use Django 1.3.

sample/
static/
js/jquery.1.6.1.min.js
css/

settings.py

APP_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(APP_DIR, 'static/')
STATIC_URL = 'http://192.168.1.141:44/static/'
TEMPLATE_DIRS = (
os.path.join(APP_DIR, 'templates/')
)

urls.py

from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns('',
(r'^$', 'hydra.views.index'),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root':'/django/spl/kk/static'}),
)

The above settings works.

Thanks

Madhu

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: python code works in command line but not in django

Hi Bruno,

I tested with both system's python shell and the "manage.py shell",
and both of them also worked. The PNG file was created properly.

I also check the path returned from os.path.abspath() and both of them
are ok as well.

Now I am testing using the Django embedded development server.

Kann

On May 31, 12:19 pm, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On May 31, 11:29 am, Kann <vearas...@gmail.com> wrote:
>
> > Hi All,
>
> > I apologize for now being specific enough. The java script
>
> s/script/application/
>
> Please let's not confuse Java with javascript ;)
>
> > should read
> > files in "tmp/medusa" and use "Medusa.jar" as the referenced class to
> > run. The result of the script should be a png image using data from
> > files inside "tmp/medusa"
>
> > I tested the java command via terminal and it worked fine. The PNG
> > image was created correctly.
>
> > I tested the python package using python shell
>
> bare python shell, or ./manage.py shell ?
>
> > by importing
> > MedusaConnector and run the "MedusaConnector.create_image()", and the
> > PNG image was created properly as well.
>
> > Therefore, I imported the Medusa package into my views.py and try to
> > run it using django. This time, the PNG file was created, but with and
> > empty image unlike those 2 previous test cases.
>
> > Really have no idea what's going on here...
>
> Check you path. FWIW:
>
> Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
> >>> import os
> >>> os.getcwd()
> '/home/bruno'
> >>> os.path.abspath('tmp')
> '/home/bruno/tmp'
> >>> os.chdir('/home')
> >>> os.path.abspath('tmp')
> '/home/tmp'
>
> Also are you running Django with the embedded development server (./
> manage.py runserver) or behind Apache or another front web server ? In
> the second case, you may have issues with ENV, perms etc.
>
> HTH

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: python code works in command line but not in django

On May 31, 11:29 am, Kann <vearas...@gmail.com> wrote:
> Hi All,
>
> I apologize for now being specific enough. The java script

s/script/application/

Please let's not confuse Java with javascript ;)

> should read
> files in "tmp/medusa" and use "Medusa.jar" as the referenced class to
> run. The result of the script should be a png image using data from
> files inside "tmp/medusa"
>
> I tested the java command via terminal and it worked fine. The PNG
> image was created correctly.
>
> I tested the python package using python shell

bare python shell, or ./manage.py shell ?

> by importing
> MedusaConnector and run the "MedusaConnector.create_image()", and the
> PNG image was created properly as well.
>
> Therefore, I imported the Medusa package into my views.py and try to
> run it using django. This time, the PNG file was created, but with and
> empty image unlike those 2 previous test cases.
>
> Really have no idea what's going on here...

Check you path. FWIW:

Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getcwd()
'/home/bruno'
>>> os.path.abspath('tmp')
'/home/bruno/tmp'
>>> os.chdir('/home')
>>> os.path.abspath('tmp')
'/home/tmp'
>>>

Also are you running Django with the embedded development server (./
manage.py runserver) or behind Apache or another front web server ? In
the second case, you may have issues with ENV, perms etc.

HTH

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Is there an HTML editor that's Django-aware

On 31 May 2011, at 00:20, AJ wrote:

> If I can give my $0.02, the content can live anywhere, but how about at least a link to the content within the initial "setting up django environment' section?
>
> This way those who are just beginning programming and Django can know what do they need to do and what are the pros and cons of an editor/ide upfront.

Agreed. An editor section at the start would be useful. I'm guessing that quite a few people who are new to Django are also new to Python as well (in the same way as many new Rails users are new to Ruby) so any help in getting them started with Python as a whole as well as in a Django specific way will be helpful.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Passing parameters to form class

Hello,

I've hit a brick wall while trying to create dynamic forms.
Basically I am trying to give parameter to a class form and then based
on that do a multiple choice questionaire.

For example

def somefunction():
formi = someForm(ids='1')

class someForm(forms.Form):
# get id from, use it to get some information from a model and then
based on that create a multiplechoice questionnaire. Or better yet do
the model querying in somefuntion and only pass the results to
someForm.

*****
Inside someForm I can create a tuple and then use this tuple to do a
MultipleChoiceField but I can't for the life of me understand how I
could parametrize this.

So this works:
C = (('a','a'), ('b','b'), ('c','c'), ('d','d'),)
vaihtoehdot = forms.MultipleChoiceField(choices=C,
widget=forms.CheckboxSelectMultiple)

but when I try to change the C to be dynamic I get an empty form. I've
tried fiddling with the __init__ function but to no avail.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Problem with layout

Hi friends,

recently I upgraded my django installed version to 1.3. 

To test it, i got a free html/css template from a page, and started a little web. The surprise came when I open development webserver, with all static files configured properly, and the resulting website (without any modification, only serving the same web template from django instead of filesystem) is wider, and some parts are malformed.

I used the same html template (without modifications), and the same images and CSS (CSS only modified to get properly routes).

Then, i set the same index.html and served from django server as static file (without using django routes, only servinc static html file). This file is malformed too, at the same way as serving as django page. The last test was to open that html file, from the same browsers, but this time from filesystem, instead of from django. File display correctly all layout.

Any idea about what is happening?

Thanks in advance

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Serving static file on Windows

Hi,


I use Django 1.3.

sample/
static/
js/jquery.1.6.1.min.js
css/

settings.py

APP_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(APP_DIR, 'static/')
STATIC_URL = 'http://192.168.1.141:44/static/'
TEMPLATE_DIRS = (
os.path.join(APP_DIR, 'templates/')
)

urls.py


from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns('',
(r'^$', 'hydra.views.index'),
)

The above settings works.


Thanks

Madhu

On May 31, 9:44 am, Praveen Krishna R <rpraveenkris...@gmail.com>
wrote:
> *Pasting one of my earlier replies to the same question*
> ***
> *
> *Please check django official docs to find out how static files are served
> on production and development server.
>
> in the dev server include a similiar snippet into your projects
> urls.py, urlpatterns:
>
> (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',{'document_root':
> 'D:/djangoprojects/praveensprofile/templates/static'}),
>
> and in the templates something similar to the below text.
> <link href="/site_media/default.css" rel="stylesheet" type="text/css" />
>
> *
>
>
>
>
>
>
>
>
>
> On Mon, May 30, 2011 at 1:57 PM, Alagu Madhu <alma...@gmail.com> wrote:
> > urls.py
>
> > from django.conf.urls.defaults import patterns, include, url
>
> > urlpatterns = patterns('',
> >    (r'^$', 'hydra.views.index'),
> >    )
>
> > On May 30, 12:28 pm, Praveen Krishna R <rpraveenkris...@gmail.com>
> > wrote:
> > > *could you dump your urls.py ?
> > > *
>
> > > On Mon, May 30, 2011 at 12:19 PM, Alagu Madhu <alma...@gmail.com> wrote:
> > > > Hi,
>
> > > > sample/
> > > >                     static/
> > > >                    js/jquery.1.6.1.min.js
> > > >                 css/
>
> > > > settings.py
>
> > > > APP_DIR = os.path.abspath(os.path.dirname(__file__))
> > > > STATIC_ROOT = os.path.join(APP_DIR, 'static/')
> > > > STATIC_URL = '/static/'
> > > > INSTALLED_APPS = (
> > > >    'django.contrib.auth',
> > > >    'django.contrib.contenttypes',
> > > >    'django.contrib.sessions',
> > > >    'django.contrib.sites',
> > > >    'django.contrib.messages',
> > > >    'django.contrib.staticfiles',
> > > > )
>
> > > > urls.py
>
> > > > urlpatterns = patterns('',
> > > >    (r'^$', 'hydra.views.index'),
> > > > )
>
> > > >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> > > > Page not found (404)
> > > > 'js\jquery.1.6.1.min.js' could not be found
>
> > > > Thanks
>
> > > > Madhu
>
> > > > On May 24, 9:44 pm, shofty <m...@shofty.me> wrote:
> > > > > ignore that last comment, im clearly behind a version!
>
> > > > > not sure why you're needing to static.serve the static files, if
> > > > > you're on django 1.3 it does that bit for you.
>
> > > > > On May 24, 9:22 am, AlaguMadhu<alma...@gmail.com> wrote:
>
> > > > > > Hi,
>
> > > > > > sample/
> > > > > >           media/
> > > > > >                     js/jquery.1.6.1.min.js
> > > > > >                  css/
> > > > > >            static/
> > > > > >                     js/jquery.1.6.1.min.js
> > > > > >                  css/
>
> > > > > > settings.py
>
> > > > > > import os
> > > > > > PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
> > > > > > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
> > > > > > MEDIA_URL = '/media/'
> > > > > > STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
> > > > > > STATIC_URL = '/static/'
>
> > > > > > urls.py
>
> > > > > > urlpatterns = patterns('',
> > > > > >     (r'^media/(?P<path>.*)$', 'django.views.static.serve',
> > > > > > {'document_root': settings.MEDIA_ROOT}),
> > > > > >     (r'^static/(?P<path>.*)$', 'django.views.static.serve',
> > > > > > {'document_root': settings.STATIC_ROOT}),
>
> > > > > >http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> > > > > > Page not found (404)
> > > > > > 'js\jquery.1.6.1.min.js' could not be found
>
> > > > > > Thanks
>
> > > > > >Madhu
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscribe@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > Thanks and Regards,
> > > *Praveen Krishna R*
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Thanks and Regards,
> *Praveen Krishna R*

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

BadValueError: Property title is required

Hello,

I'm trying to create simple method to create category. I set the model
category:

class Category(db.Model):
title = db.StringProperty(required=True)
clashes_count = db.IntegerProperty(default=0)

And the class New Category as well :

class NewCategoryPage(webapp.RequestHandler):
def get(self):
categories = Category.all().order('-title')

template_values = { }
path = os.path.join(os.path.dirname(__file__), 'templates',
'category_new.html')
self.response.out.write(template.render(path, template_values))

def post(self):
category = Category()
category.title = self.request.get('title')
category.put()
self.redirect('/')

Here is the template:

{%extends "base.html"%}
{%block body%}

<h2>Add New Category</h2>

<form action="" method="post">
<div>Title: <input type="text" name="title" size="100" /></div>
<div><input type="submit" value="Publish"></div>
</form>

{%endblock%}

The problem is that I'm getting an error BadValueError: Property title
is required. Can you help me with that ? Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: python code works in command line but not in django

Hi All,

I apologize for now being specific enough. The java script should read
files in "tmp/medusa" and use "Medusa.jar" as the referenced class to
run. The result of the script should be a png image using data from
files inside "tmp/medusa"

I tested the java command via terminal and it worked fine. The PNG
image was created correctly.

I tested the python package using python shell by importing
MedusaConnector and run the "MedusaConnector.create_image()", and the
PNG image was created properly as well.

Therefore, I imported the Medusa package into my views.py and try to
run it using django. This time, the PNG file was created, but with and
empty image unlike those 2 previous test cases.

Really have no idea what's going on here...

Kann

On May 31, 10:48 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On May 31, 10:32 am, Lucian Nicolescu <lucia...@gmail.com> wrote:
>
> > I don't think there's any way this could work.
>
> Oh yes ? Why so ?
>
> > From what I can tell
> > Kann is trying to invoke the java interpreter ...
>
> Indeed.
>
> > but he does it on
> > the server, not on the user's machine
>
> And ?
>
> > - that's why it only works when the two are the same.
>
> Please think twice before posting.
>
> The OP never talked about "code working on it's own machine and not on
> the production server", but about "code working from within the python
> shell and not from the views". Not quite the same problem.
>
> FWIW, nothing prevents a java interpreter from being launched on the
> same machine as the django app (it's even a rather common use case),
> and as long as everything is correctly deployed and the env, path and
> perms are ok there's no reason it shouldn't work as well on a dev
> workstation, staging server or production server.
>
> > So he should try to invoke it somehow else, maybe embed it in a html
> > page if it's a Applet or just link to the .jar file directly and
> > normally the Java machine will automatically pick it up (if installed
> > on the user's machine).
>
> What makes you think the java program is supposed to run on the user
> machine exactly ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: python code works in command line but not in django

Hey Bruno,

Sorry if I misunderstood the initial posting, please enlighten me/us
with a solution for the problem.

Lucian

On Tue, May 31, 2011 at 11:48 AM, bruno desthuilliers
<bruno.desthuilliers@gmail.com> wrote:
>
> On May 31, 10:32 am, Lucian Nicolescu <lucia...@gmail.com> wrote:
>> I don't think there's any way this could work.
>
> Oh yes ? Why so ?
>
>> From what I can tell
>> Kann is trying to invoke the java interpreter ...
>
> Indeed.
>
>> but he does it on
>> the server, not on the user's machine
>
> And ?
>
>> - that's why it only works when the two are the same.
>
> Please think twice before posting.
>
> The OP never talked about "code working on it's own machine and not on
> the production server", but about "code working from within the python
> shell and not from the views". Not quite the same problem.
>
> FWIW, nothing prevents a java interpreter from being launched on the
> same machine as the django app (it's even a rather common use case),
> and as long as everything is correctly deployed and the env, path and
> perms are ok there's no reason it shouldn't work as well on a dev
> workstation, staging server or production server.
>
>
>> So he should try to invoke it somehow else, maybe embed it in a html
>> page if it's a Applet or just link to the .jar file directly and
>> normally the Java machine will automatically pick it up (if installed
>> on the user's machine).
>
> What makes you think the java program is supposed to run on the user
> machine exactly ?
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Model 'Child' is inherited from 'Parent', trying to filter to get only Child results with Parent.objects.filter(...)

Example code:

class Parent(models.Model):
name = models.CharField(max_length='20',blank=True)

class Child(Parent):
pass

I want to get the result of Child.objects.all() but I DO NOT want to
use Child.
I want to use Parent instead, which I tried to do with:

Parent.objects.filter(child__isnull=False)

Which doesn't work and gives the result of Product.objects.all()
instead.
However If I do the following, it WORKS:

Parent.objects.filter(child__name__isnull=False)

Another way, if I insist on using
Parent.objects.filter(child__isnull=False), is to change the Child
model to the following:

class Child(models.Model):
parent = models.OneToOneField(Parent)

Then Parent.objects.filter(child__isnull=False) would WORK

The problem with the 2 solutions above is that filtering with
child__name__isnull looks hackish, and I don't want to change my Child
model to use OneToOneField.

So is there a better way?

Thanks,
Robin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.