Re: Writing your first Django app

2008-12-29 Thread Briel

The quick answer:
This goes into views.py (copied from the tutorial).

def detail(request, poll_id):
return HttpResponse("You're looking at poll %s." % poll_id)

Now to understand what happens a bit better:
In your views.py file you can make as many "def something(request):"
as you like. This is where you write your code to handle what or how
you'll make some http response. In your urls.py you write what model
in your views.py need to handle what urls. So when you write an url,
Django will find out if that is a valid url, comparing to the urls you
have in your urls.py file(s). If there is a match, then it will run
the model in your views file.

In the code from the tutorial, 'mysite.polls.views.detail' will run
the above code, if it's written in the views.py in your polls app. It
returns a simple http response, a text string: "You're looking at poll
%s." % poll_id. The poll_id varible is gotten from the url.

-Briel


johan skrev:
> yes of course my bad!
>
> http://docs.djangoproject.com/en/dev/intro/tutorial03/#intro-tutorial03
>
>
>
> 2008/12/29 Abdel Bolanos Martinez 
>
> >  send me the url of the tutorial  where you are, now!!!
> >
> >
> > On Mon, 2008-12-29 at 06:19 -0800, kallep wrote:
> >
> > that was a fast reply :)
> >
> > In  part 3 I do not understand if I'm suppose to create a new view
> > called detail.py or if this code should be in to the views.py. The
> > problem is that I cant load the detail page or even figure out if I'm
> > supposed to be able to do that. I do not know what I'm building here!
> >
> > On Dec 29, 10:02 pm, Abdel Bolanos Martinez 
> > wrote:
> > > what you have just done until now ???
> > >
> > > On Mon, 2008-12-29 at 05:52 -0800, kallep wrote:
> > > > This is my first question here.  I find it extremely difficult to
> > > > follow the "Writing your first Django app tutorial".  I'm  now stocked
> > > > on the third part. Is it possible to see the finished source code
> > > > somewhere?   The main difficulty is to understand what code are
> > > > supposed to go where.
> > >
> > > Abdel Bola�os Mart�nez
> > > Ing. Inf�rmatico
> > > Telf. 266-8562
> > > 5to piso, oficina 526, Edificio Beijing, Miramar Trade Center. ETECSA
> >
> >
> >
> >
> > Abdel Bola�os Mart�nez
> > Ing. Inf�rmatico
> > Telf. 266-8562
> > 5to piso, oficina 526, Edificio Beijing, Miramar Trade Center. ETECSA
> > >
> >

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: need urls help

2008-12-29 Thread Briel

A solution, not sure if it's the best, would be to make a function in
basicly any file, that generates a quote. Then you can import the
function to every view you want and call it to get the random quote.
All you need then is to pass it to your html-file (and display it).
You could just write a bit of html for it, in your base html, that you
extend.

Bobby Roberts skrev:
> hi group.
>
> I have an issue where I need a random quote to display on every page
> on my website.  Writing the view is not a problem (at least I don't
> think it is), but how would I call the view on each page of my website
> in the urls 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: working with a returned object inside another class

2008-12-30 Thread Briel

Just a tip if you're not familiar with SQL, you can get django-
evolution. It works with syncdb, in that syncdb will detect when an
"evolution" of the db is needed like in the example above. It can't do
everything, but it can do a lot if things for you, with some simple
commands.

A second thing. [:1] will return a list with the first item only,
however, [1] will return not the first item, but the second item of
the list. If you want the first item, you should use [0] instead as
python like counting from 0.

On Dec 30, 5:36 am, garagefan  wrote:
> Thanks, that worked perfectly. right now i can lose the data as i'm
> still learning this all. I will have to look into editing the DB via
> the shell for future fixes
>
> On Dec 29, 11:20 pm, Daniel Roseman 
> wrote:
>
> > On Dec 29, 11:04 pm, garagefan  wrote:
>
> > > awesome... it was all in that [:1]!
>
> > > now, next issue...
>
> > > "OperationalError at /admin/galleries/gallery/
> > > (1054, "Unknown column 'galleries_gallery.status' in 'field list'")"
>
> > > i just added the status field as i wasn't worried about any of that
> > > previously... now, it appears to be causing issues. I've ran syncdb,
> > > but it doesn't seem to be adding this new column. I gather it is very
> > > very important to consider your required fields before syncing
> > > originally... how do i go about fixing this issue?
>
> > > thanks again
>
> > Syncdb doesn't modify existing tables. If you don't have any data you
> > need to keep, you can run
> > ./manage.py reset galleries
> > Note that this will completely delete and recreate your tables. If you
> > want to preserve existing data, you'll need to go into your database
> > shell (via ./manage.py dbshell) and run the SQL to modify your table
> > manually - something like
> > ALTER TABLE `galleries_gallery` ADD COLUMN `status` VARCHAR(1) NOT
> > NULL;
> > (guessing at the column definition, change as required).
>
> > --
> > 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: select childless parents, i.e. base with no derived classes in model inheritance

2008-12-30 Thread Briel

The first query looks at the restaurant attribute in the place model,
and gets all that have a NULL value in that field. Now  I don't know
the restaurant/place setup, the docs I read uses book/auther examples.
It looks like that the restaurant field is ForeignKey, and should be
able to work the way intended. It would do a lookup for all places
that doen't have a restaurant object associate with it. But, if the
restaurant field is a BoolianField instead, then you can't use
is_null, as both True and False isn't Null.

Hope this helps, else be a little more explicit about the
relationships.

-Briel

On Dec 30, 5:23 am, pk  wrote:
> Alex,
>
> First I made a mistake in the original post. The first query returns
> *nothing*, not "all places". This is the correct "question:
>
> 1) print Place.objects.filter(restaurant__isnull=True).count()
>
> returns 0
>
> and 2) print Place.objects.filter
> (restaurant__serves_hotdog__isnull=True).count()
>
> works correctly, returning a count of all Places that is not a
> restaurant.
>
> The first query does not even join the child table. It tries to do:
>
> SELECT COUNT(*) FROM "place" WHERE "place"."id" IS NULL
>
> Where as the second query does a LEFT OUTER JOIN between parent and
> child table, then
> added a where clause to test for the hotdog field being null,
> essentially filtered out the rows
> that have no hotdog fields at all.
>
> Seems like query 1 is broken?
>
> P.K.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Please help me anyone

2009-01-04 Thread Briel

Hi.
You could say that Django is an extension of python, so first thing to
do would be to learn the basics in python. A good and free starter
book I 've read myself and found quite good is called, "How to think
like a computer scientist". It teaches a lot of things using only
python and is easy and quick to read and has some good exercises. You
can learn the way python work ect with that book.
link: http://openbookproject.net/thinkCSpy/index.xhtml

After getting the basics of python down, I would suggest that you
start out with the Django Tutorial, it's a great way to learn the way
Django works. Then as you are working on actual projects, you can
browse the documentation when you need to do things you do not know
how to do. The Django documentation is very well written, and explains
a lot things is great detail.

-Briel

priyankeshu skrev:
> ok... i am good at html and CSS and i have done little bit of old
> school C programming and databases i have never got a chance to work
> on real world programming projects
>
> i am looking for an online guru (to teach me python/django) i want to
> learn how to build websites in python. You can guide me by doin things
> remotely on my pc
>
> i don't want to use php for some reason
>
> send me a message or add me at priyankeshu.parihar at gmail.com on
> google talk...
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Change the url

2009-01-08 Thread Briel

Hi.
Instead of manually writing the url, you can instead use the {% url %}
tag, then Django would figure out what the correct url is. If you are
using url tags you should considder using named urls. The link with
url tag would end up something like this: {{n.list_channel}}

read about the url tag in the Django Doc
http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#url

-Briel

Praveen skrev:
> MODELS.py
>
> class Listing_channels(models.Model):
> list_channel = models.CharField(max_length = 20)
> visibility = models.BooleanField()
>
> def __unicode__(self):
> return self.list_channel
>
> class Listing(models.Model):
>   name = models.CharField(max_length=20)
>   description = models.TextField(max_length = 100)
>   website = models.URLField()
>   timing = models.CharField(max_length=20)
>   channels = models.ForeignKey(Listing_channels)
>   visibility = models.BooleanField()
>
>   def __unicode__(self):
>   return self.name
>
>URLS.py
>
>  (r'^category/listing_view/(?P\w+)/
> $','mysite.library.views.listing_view'),
>
>VIEWS.py
>
> def listing_view(request, id):
> report_list = get_object_or_404(Listing_channels, pk = id)
> listing_result = Listing_channels.objects.all()
> r = report_list. listing_set.all()
> print r
> return render_to_response("list_listing.html", {'report_list' :
> report_list,'r':r,'listing_result':listing_result})
>
>
> list_listing.html
>
> 
> Sight Seeings
> 
> {%if listing_result %}
> {% for n in listing_result %}
> {{n.list_channel}}
> {% endfor %}
> {% else %}
> not available
> {% endif %}
> 
> 
>  
>  {% if report_list  %}
>
>  
>   
>height="100px">Sight
> Seeings Details
>   
>   
>   
>   
> {% for t in r %}
> 
>   {{ t.name }}
> 
> 
>   {{ t.timing }}
> 
> 
>   {{ t.description }}
> 
> 
>   {{ t.website }}
> 
> 
> {% endfor %}
>   
>  {% else %}
>No names found
>
>   {% endif %}
>   
>
> I am displaying Listing_channels and Listing on same page. if some one
> click on any Listing_channels the corresponding Listing must display
> on same page. that is why i am also sending the Listing_channels
> object to list_listing.html page. if some one click first time on
> Listing_channels it shows the url 
> http://127.0.0.1:8000/category/listing_view/1/
> but second time it appends 1 at the end and the url becomes
> http://127.0.0.1:8000/category/listing_view/1/1
>
> I am trying to display like frameset left side all channels and right
> side description of that channel.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Change the url

2009-01-08 Thread Briel

Using urls with names will solve your problem.

Basically if you change your urls.py like this:

url(
r'^category/listing_view/(?P\w+)/$',
   'mysite.library.views.listing_view',
   name = 'name_for_this_view'
),

What I have done is to add a name to the url for convenience I also
used the url() function. This name can now be used instead of the link
to your view. So if you were to change the site structure, when
changes would be made to your urlconf, django would then be able to
figure things out for you. In this version your new link would look
like this:

{{n.list_channel}}


In the docs you can read about it at
url(): http://docs.djangoproject.com/en/dev/topics/http/urls/#url
naming: http://docs.djangoproject.com/en/dev/topics/http/urls/#id2

Good luck.
-Briel

On 8 Jan., 12:41, Praveen  wrote:
> Hi Malcolm i am very new bie of Django. i read through
> get_absolute_url but do not know how to use.
> What you have given the answer i tried with that and its working fine
> but my senior asked me what will happen if i change the site name then
> every where you will have to change url
> mysite.library.views.listing_view.
>
> so they told me to use get_absolute_url
>
> i wrote get_absolute_ul in models.py
>     def get_absolute_url(self):
>         return "/listing/%i/" % self.id
> and i am trying to use in my html page template but i don't know how
> to use
>
>  {{n.list_channel}} li>
>
> then again same problem. first time when some one click on link it
> works fine but second time it appends the link 
> likehttp://127.0.0.1:8000/category/listing_view/3/3
>
> Please give me some idea
>
> On Jan 8, 3:37 pm, Praveen  wrote:
>
> > Thank you so much Malcolm.
> > every one gives only the link and tell to read but your style of
> > solving the problem is amazing. how you explained me in a nice way
> > that i can never ever find in djangoproject.com.
> > Thanks you so much malcom
>
> > On Jan 8, 3:23 pm, Malcolm Tredinnick 
> > wrote:
>
> > > I'm going to trim your code to what looks like the relevant portion of
> > > the HTML template, since that's where the easiest solution lies.
>
> > > On Thu, 2009-01-08 at 02:02 -0800, Praveen wrote:
>
> > > [...]
>
> > > >     list_listing.html
>
> > > > 
> > > > Sight Seeings
> > > > 
> > > > {%if listing_result %}
> > > >     {% for n in listing_result %}
> > > >         {{n.list_channel}}
> > > >     {% endfor %}
> > > > {% else %}
> > > >     not available
> > > > {% endif %}
> > > > 
> > > > 
>
> > > [...]
>
> > > > I am displaying Listing_channels and Listing on same page. if some one
> > > > click on any Listing_channels the corresponding Listing must display
> > > > on same page. that is why i am also sending the Listing_channels
> > > > object to list_listing.html page. if some one click first time on
> > > > Listing_channels it shows the 
> > > > urlhttp://127.0.0.1:8000/category/listing_view/1/
> > > > but second time it appends 1 at the end and the url becomes
> > > >http://127.0.0.1:8000/category/listing_view/1/1
>
> > > The above code fragment is putting an element in the template that looks
> > > like
>
> > >         ...
>
> > > That is a relative URL reference and will be relative to the URL of the
> > > current page (which is .../category/listing_view/1/). In other words, it
> > > will be appended to that URL. One solution is to change the relative
> > > reference to look like
>
> > >         ...
>
> > > or, in template language:
>
> > >         {{n.list_channel}}
>
> > > That assumes you will only be displaying this template
> > > as /listing_view/1/ (or with a different number as the final
> > > component), since it will *always* remove the final component and
> > > replace it with the id value.
>
> > > The alternative, which is a little less fragile, is to use the "url"
> > > template tag to include a URL that goes all the way back to the hostname
> > > portion. You could write
>
> > >         {{n.list_channel}}
>
> > > (I've put in some line breaks just to avoid unpleasant line-wrapping).
> > > The {% url ... %} portion will return "/category/listing_view/1/" -- or
> > > whatever the right n.id value is -- which will always be correct.
>
> > > Have a read 
> > > ofhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#urlif
> > > you're not familiar with the URL tag.
>
> > > Regards,
> > > Malcolm
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Change the url

2009-01-08 Thread Briel

Hi Praveen
I personally would prefer naming the urls rather than using the
get_absolute_url.
Both can accomplish your goal, but naming the urls is a more robust
and in other ways a better solution.

If you in a week decide that the url should not be /category/... but
instead /whatever/... you would have to recode your get_absolute_url
method. However, if you use the names in urls, everything would still
work after changing the urls. The reason is that when using the name
of an url, Django will find what the absolute url will be given the
args you use, in your example the id.
In a way, you could say that when using named urls, django is both
writing and running get_absolute_url for you.

Another plus when using named urls, is that you can give your urls
name that give meaning. That will make it a lot easier to understand
what's going on in the template when you read your own code 6 months
from now. Especially if you have several views of one model.

Say you had a model for blog posts.
Then you might want to have an url for your own blogs, another one for
your friend's blogs ect. You could still use get_absolute_url, but
this time, it would be harder to make and use, as you now would need
to know what url to get. Also when reading the template it would be
hard to see which url is being displayed. Instead using tags like
{% url friends_blog args=x %}
{% url your_blog args=x %}
{% url all_blog args=x %}
would be easy to understand after not working with the code for a long
time.

-Briel

Praveen wrote:
> Hi Briel i am totally confused now.
> My senior told me to write get_absolute_url
>
> so i wrote get_absolute_url like this
> class Listing_channels(models.Model):
> list_channel = models.CharField(max_length = 20)
> visibility = models.BooleanField()
>
> def __unicode__(self):
> return self.list_channel
>
> def get_absolute_url(self):
>   return u'/category/listing_view/%i/' % self.id
>
> and in html template i am calling
>
> {%if listing_result %}
> {% for n in listing_result %}
>  {{n.list_channel}} li>
> {% endfor %}
> {% else %}
> not available
> {% endif %}
> 
>
> so its working fine.
>
> so now i have two mechanism one is your as you told me to write and
> second one is
> get_absolute_url() function.
>
> Now my confusion is if we have another same class event_channel and
> event and many more classes like this then i will have to write
> get_absolute_url() for each class
> and if go with you then there i need to change only in urls.py that i
> think fine.
>
> so i should go with get_absolute_url? give me the best and solid
> reason so i could make understand to senior, and you know the senior
> behave..
>
>
> Briel wrote:
>
> > Using urls with names will solve your problem.
> >
> > Basically if you change your urls.py like this:
> >
> > url(
> > r'^category/listing_view/(?P\w+)/$',
> >'mysite.library.views.listing_view',
> >name = 'name_for_this_view'
> > ),
> >
> > What I have done is to add a name to the url for convenience I also
> > used the url() function. This name can now be used instead of the link
> > to your view. So if you were to change the site structure, when
> > changes would be made to your urlconf, django would then be able to
> > figure things out for you. In this version your new link would look
> > like this:
> >
> > {{n.list_channel}}
> >
> >
> > In the docs you can read about it at
> > url(): http://docs.djangoproject.com/en/dev/topics/http/urls/#url
> > naming: http://docs.djangoproject.com/en/dev/topics/http/urls/#id2
> >
> > Good luck.
> > -Briel
> >
> > On 8 Jan., 12:41, Praveen  wrote:
> > > Hi Malcolm i am very new bie of Django. i read through
> > > get_absolute_url but do not know how to use.
> > > What you have given the answer i tried with that and its working fine
> > > but my senior asked me what will happen if i change the site name then
> > > every where you will have to change url
> > > mysite.library.views.listing_view.
> > >
> > > so they told me to use get_absolute_url
> > >
> > > i wrote get_absolute_ul in models.py
> > > � � def get_absolute_url(self):
> > > � � � � return "/listing/%i/" % self.id
> > > and i am trying to use in my html page template but i don't know how
> > > to use
> > >
> > >  {{n.list_channel}} > > li>
> > >
> > > then again same problem. first time when some one click on link it
> > > works fine but second time it append

Re: Change the url

2009-01-09 Thread Briel

Hi Praveen
It's not always an easy task being a developer.

However, I don't see the point in using Django, if you're not also
using all of the tools that available because you need a designer that
only know strict HTML, and don't know anything about the process. With
all the vars and tags you're already using like {% for %} ect, I have
a hard time seeing the advantage using such designers. I but guess it
all comes down to how you want to organize things, and here it's the
seniors that make that choice. Not a situation I myself am in.

If you have to write get_absolute_url(), you should get a read on
reverse() that kip wrote about. It can get the urls for you in most
cases.

Good Luck with the project.
-Briel

On 9 Jan., 10:20, Praveen  wrote:
> Hi Briel again my senior gave me other idea and they gave me a nice
> reason why they want me to use get_absolute_url()
>
> Given our new understanding of what the best practice is, the workflow
> for a template designer, who shouldn’t need to know or understand
> programming, is:
>
>    1. Ignore the documentation’s preference for {% url %} and use what
> makes sense in a given circumstance.
>    2. In order to know what makes sense in a given circumstance,
> figure out whether the view you want to link to is an object detail
> view or not.
>    3. If it’s an object detail view, use get_absolute_url.
>    4. If not, dig through the Python code to find the friendly name
> your programmer has given to the view you want to link to. You’ll want
> to look at URL configurations for this. Please note that these URL
> configurations may be strewn across many apps, including some third-
> party apps that don’t reside in your project at all. Just read the
> Python import statements in your base URL configuration and you should
> be able to find them. Don’t know what a Python import statement or a
> base URL configuration is?
>    5. Once you’ve found the friendly name, read the regular
> expressions in the URL configuration to figure out what arguments need
> to be passed to the {% url %} tag. It may help to find and read the
> associated view function. I know you probably don't know Python or
> regular expressions, but sometimes life is hard.
> Construct your {% url %} tag. Use filters to parse data like dates and
> times into the format expected by your view function. If the filter
> you're looking for doesn't exist, you may need to write it. Except you
> can't, because you don't know Python. Sorry about that.
> Be very careful not to make any typos in your {% url %} tag, or you
> will almost certainly face a NoReverseMatch exception, which will be
> nonsense to you and very difficult to debug.
>
> If you find yourself in a situation with designers who would have
> trouble fully grasping all the steps you’ve outlined above (and that’s
> no knock on the designers, that shouldn’t really be their main job),
> then the job falls to the developer to make it simpler.
>
> For the rest of the cases — namely, those where you’re dealing with a
> name plus arguments and you’re going to be using it over and over (and
> hence it’ll be tedious to write out a {% url %} call every time), your
> friendly local developer can supply you with a shortcut in the form of
> a method you can hit on an object, decorated with permalink, as often
> happens with get_absolute_url.
>
> It’s also worth noting that you can often simplify repetition within a
> template by using one of the newer features of the {% url %} tag: in
> the form {% url some_pattern_name arg1=foo,arg2=bar as some_url %}, it
> sets the variable some_url for reuse.
>
> So basically, to me, this comes down to developers and designers
> working together to share information: designers explaining what they
> need in terms of backend support, and developers explaining what
> support they can provide and how to use it.
>
> I think their points are also positive and now i am going to use
> get_absolute_url().
>
> On Jan 8, 6:43 pm, Briel  wrote:
>
> > Hi Praveen
> > I personally would prefer naming the urls rather than using the
> > get_absolute_url.
> > Both can accomplish your goal, but naming the urls is a more robust
> > and in other ways a better solution.
>
> > If you in a week decide that the url should not be /category/... but
> > instead /whatever/... you would have to recode your get_absolute_url
> > method. However, if you use the names in urls, everything would still
> > work after changing the urls. The reason is that when using the name
> > of an url, Django will find what the absolute url will be given the
> > args you use, in your example the id.
> > In a way, you could say that when using named urls, django 

Re: the last line is plone\Python\lib\site-packages\django\db\backends\sqlite3\base.py

2009-01-14 Thread Briel

Yes, that should work.
All you need is to create the db-file, and then give the name/path to
it in settings.py

-Briel

On 14 Jan., 21:18, bconnors  wrote:
> my bad. i read that sqlite3 was supplied by python 2.5. i have python
> 2.4. the base.py says sqlite2 is correct for prior to python 2.5, but
> that didn't work either. tomorrow i install python 2.5. will that
> work?
>
> On Jan 14, 2:16 pm, bconnors  wrote:
>
> > In the settings.py it says “ If you're new to databases, we recommend
> > simply using SQLite (by setting DATABASE_ENGINE to 'sqlite3').”
>
> > I did that but get this error:
>
> > C:\PROGRA~1\plone\Python\jan13django\mysite>..\..\python manage.py
> > syncdb
>
> > Traceback (most recent call last):
> >   File "manage.py", line 11, in ?
> >     execute_manager(settings)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\__init
> > __.py", line 340, in execute_manager
> >     utility.execute()
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\__init
> > __.py", line 295, in execute
> >     self.fetch_command(subcommand).run_from_argv(self.argv)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\base.p
> > y", line 195, in run_from_argv
> >     self.execute(*args, **options.__dict__)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\base.p
> > y", line 221, in execute
> >     self.validate()
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\base.p
> > y", line 249, in validate
> >     num_errors = get_validation_errors(s, app)
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\core
> > \management\valida
> > tion.py", line 22, in get_validation_errors
> >     from django.db import models, connection
> >   File "C:\PROGRA~1\plone\Python\Lib\site-packages\django\db
> > \__init__.py", line
> > 16, in ?
> >     backend = __import__('%s%s.base' % (_import_path,
> > settings.DATABASE_ENGINE),
> >  {}, {}, [''])
> >   File "C:\PROGRA~1\plone\Python\lib\site-packages\django\db\backends
> > \sqlite3\ba
> > se.py", line 28, in ?
> >     raise ImproperlyConfigured, "Error loading %s module: %s" %
> > (module, exc)
> > django.core.exceptions.ImproperlyConfigured: Error loading sqlite3
> > module: No module named sqlite3
>
> > C:\PROGRA~1\plone\Python\jan13django\mysite>
>
> > Any ideas?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Adding a view inside a view?

2009-01-14 Thread Briel

I'm not sure exactly what you want. Do you want a single poll, that
the admins can choose? Should users be able to create polls ect.
Anyways, in case you only want to display a single poll, the easiest
way to accomplish that would probably to create a boolean field called
display or front_page. Then you can import your poll model and filter
on it and get the one(s) that have True value for front_page. If you
want to make sure that only one can be displayed on the front page at
a time, you can create a method instead, that also will hold True/
False, but only allow one to be True at a time. You could also go with
the boolean field and just add the code in a view to make sure only
one is True at a time.

Hope this helps.
-Briel

On 14 Jan., 19:42, Bradley  wrote:
> I'm new to Django and I'm trying to modify an existing django website
> for a local newspaper.  They would like to have a polls on the their
> website.  I just used the tutorial from the djangoproject website to
> create the polls module.  It works fine, except that I need it to work
> inside a  section on the front page, not multiple pages like is
> used in the tutorial.  What is the standard procedure for something
> like this?
>
> The tutorial had me create entries for /polls/ in urls.py  I probably
> don't need those.
> Do I somehow Integrate the polls function into already existing
> function that are used to display the front page?  Not really sure how
> to proceed
>
> Any help would be appreciated.
>
> Thanks,
> Brad
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Invalid block tag: "get_comment_count"

2009-01-19 Thread Briel

Hi

It's hard to say what's going wrong with the code you provided, but I
can say a few things. Since you don't get an error from {% load
comments %}, there should be no problems with the installation.
However, you might not actually run the command in the template, it
could be that you are writing it over with an extend tag. The error
hints that get_comment_count is an invalid tag, so you should test if
comments is loaded probably in your template.
Try loading comments directly above your tag and see what happens and
take it from there.

-Briel

On 19 Jan., 21:01, Florian Lindner  wrote:
> Hello,
>
> I'm trying to use the comment framework from Django 1.0.2.
>
> I've followed all the steps 
> inhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/
>   (added it to installed apps, added to urls.py and loaded in the  
> template: {% load comments % }) but I get:
>
> TemplateSyntaxError at /blog/1/
> Invalid block tag: 'get_comment_count'
>
> from:
>
> {% get_comment_count for object as comment_count %}
>
> object has just been created so probably no comment yet attached.
>
> What could have went wrong there?
>
> Thanks!
>
> Florian
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: POST sub dictionaries

2009-01-19 Thread Briel

You should really read the django docs:
http://docs.djangoproject.com/en/dev/ref/request-response/

In your first case, the latter value will overwrite the first value,
so:
request.POST['test[]'] = 1 or POST = {'test[]': 1}

In your second case, you will just have one value:
request.POST['test[key]'] = 1 or POST = {'test[key]': 1}

You can't write objects into the name of the html input tag. Whatever
you write will be just a name. You can instead send objects like
lists, dictionaries of whatever you like in posts, but you don't want
people to input those, unless it's into a form that you validate
first. If you want to know about forms in django read about it in the
docs
http://docs.djangoproject.com/en/dev/topics/forms/

-Briel


On 19 Jan., 20:35, "Vinicius Mendes"  wrote:
> Is there in django something like the PHP POST subarrays?
>
> For example, if i do this in my form:
>
> 
> 
>
> and submit it, i will have the following data structure in my PHP POST:
>
> $_POST = array(
>     'test' => array(
>         0 => 0,
>         1 => 1
>     )
> )
>
> In django, i think it can turn into:
>
> request.POST = {
>     'test': (0,1)
>
> }
>
> What means it is a dictionary with a tuple as the value of the 'test' key.
>
> Another case is this:
>
> 
>
> Whet gives this in PHP:
>
> $_POST = array(
>     'test' => array(
>         'key' => 1
>     )
> )
>
> What means the following in python:
>
> request.POST = {
>     'test': {
>         'key': 1
>     }
>
> }
>
> Is there anything like this in django? I think it can make formsets much
> more easier to use, and eliminates the needing of the management_form.
>
> 
>
> Vinícius Mendes
> Engenheiro de Computação
> Meio Código - A peça que faltava para o seu código!
> URLhttp://www.meiocodigo.com
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Invalid block tag: "get_comment_count"

2009-01-19 Thread Briel

You should try playing around with the tags, trying to load comments
different places trying some of the other comment tags to see what
happens ect.
Also are you using the block tags? what block tags do you have where
have you placed them in relation to your code?

On 19 Jan., 22:16, Florian Lindner  wrote:
> Am 19.01.2009 um 22:04 schrieb Briel:
>
> > It's hard to say what's going wrong with the code you provided, but I
> > can say a few things. Since you don't get an error from {% load
> > comments %}, there should be no problems with the installation.
> > However, you might not actually run the command in the template, it
> > could be that you are writing it over with an extend tag. The error
> > hints that get_comment_count is an invalid tag, so you should test if
> > comments is loaded probably in your template.
> > Try loading comments directly above your tag and see what happens and
> > take it from there.
>
> Hi!
>
> The complete code is:
>
> {% load comments % }
>
> 
> {% get_comment_count for object as comment_count %}
>
> So I don't there is much that could have introduced an error. I extent  
> an base template but it doesn't make any use of something called  
> comment actually it does not use any non-trivial Django markup.
>
> How can I test the comments is loaded properly?
>
> Thanks,
>
> Florian
>
>
>
> > -Briel
>
> > On 19 Jan., 21:01, Florian Lindner  wrote:
> >> Hello,
>
> >> I'm trying to use the comment framework from Django 1.0.2.
>
> >> I've followed all the steps 
> >> inhttp://docs.djangoproject.com/en/dev/ref/contrib/comments/
> >>   (added it to installed apps, added to urls.py and loaded in the
> >> template: {% load comments % }) but I get:
>
> >> TemplateSyntaxError at /blog/1/
> >> Invalid block tag: 'get_comment_count'
>
> >> from:
>
> >> {% get_comment_count for object as comment_count %}
>
> >> object has just been created so probably no comment yet attached.
>
> >> What could have went wrong there?
>
> >> Thanks!
>
> >> Florian
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Get old value of Field in ModelForm clean_* method?

2009-02-12 Thread Briel

Your problem is a bit unclear, but i think what you are looking for is
in self.data in your clean_ method

On 12 Feb., 23:56, Chris Czub  wrote:
> Is there any way to get the old value of a field in a clean_* method
> on the ModelForm?
>
> That is - the validation depends on the old value of the field versus
> the new value.
>
> self.cleaned_data only contains the new value.
>
> Thanks,
>
> Chris
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Javascript problem

2009-02-13 Thread Briel

Firefox is known to cashe things a lot, this might be the reason why
it doesn't load all the stuff. Also you should look at the page source
to see if the missing js file is listet.

On 13 Feb., 21:14, arbi  wrote:
> Ok I tryed it, and they say : "test.js is not loaded" in firebug.
> I don't see what to do next. What is strange also is that my
> background-body images are loaded on safari (no pb) and not on
> firefox...
> Any solution?
> thx
>
> On 13 fév, 18:19, felix  wrote:
>
> > use Firefox with Firebug installed if you aren't already.
>
> > you can then see if you get any 404s and if any of the included files failed
> > with syntax errors
> > or if something happened during javascript runtime to kill it
>
> > also, I like django-compress quite a bit for css and js
>
> >      felix :    crucial-systems.com
>
> > On Fri, Feb 13, 2009 at 6:11 PM, arbi  wrote:
>
> > > Thx, but I did this already. In fact i have no problem for a css doc,
> > > but problems for a js doc. I don't know why!
> > > My css is in "/media/css/css_file.css" and my js is in "/media/js/
> > > test.js". A simple "alert" in my test.js file doesn't work. I don't
> > > understand.
> > > Any help?
> > > Thx!
> > > Arbi
>
> > > On 12 fév, 23:29, Alex Gaynor  wrote:
> > > > On Thu, Feb 12, 2009 at 5:28 PM, arbi  wrote:
>
> > > > > Hi all,
>
> > > > > I am trying to execute a javascript doc to display a google map. The
> > > > > javascript doc to refer to is "google-map.js". How do I write it in
> > > > > here ? :
> > > > > TEMPLATE :
> > > > > 
> > > > > .
>
> > > > > I tryed many things and it did not work! I read many things, but I
> > > > > can't figure out how to solve this pb.
> > > > > Is there an easy solution?
>
> > > > > Thx a lot for your help
> > > > > Arbi (newb)
>
> > > > Take a look here:
> > >http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs
>
> > > > Alex
>
> > > > --
> > > > "I disapprove of what you say, but I will defend to the death your right
> > > to
> > > > say it." --Voltaire
> > > > "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: raise ValidationError has no effect

2009-02-14 Thread Briel

I dont really get your problem, but it seems that your problem is
going on in your views. When you raise a validation error the clean
method should stop right there like you say it does. It's up to you to
act on validation errors with stuff like is_valid() and do what you
want when the form doesn't validate.

On 14 Feb., 17:07, Alistair Marshall 
wrote:
> I have been trying to create a custom field that allows the user to
> enter a flowrate and clean the data back to kg/s or mol/s.
>
> I though I had everything sorted, when I type '10 tones/year', it
> correctly did the conversion however when I type something that  does
> not validate such as 'twenty' or '5 mph' the code runs till the raise
> validation error, however nothing else happens and the overall forms
> clean function gets called (which doesn't have all the fields in its
> clean_data attribute.
>
> I have posted the code on dpaste, any hints or suggestions and would
> be greatly appreciated (this is hurting my head now)
>
> http://dpaste.com/120538/
>
> Thanks
>
> Alistair
>
> http://www.thatscottishengineer.co.uk
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: need help validating imagefield in modelform..

2009-02-14 Thread Briel

Hi, I haven't much forms with image/files, but I believe you should do
something like this:
photo = self.cleaned_data.get('photo')
This is for your second version.

When doing stuff like this I find it sometimes can be helpful to
insert an error like just typing raise. Django will in the debug
screen let you look at your variables. So you could see what you fx
are getting when you do your photo = ... and see why it raised that
error.

Hope it helps
Briel

On 14 Feb., 10:52, PeteDK  wrote:
> Hi :)
>
> I'm trying to validate an uploaded image's size and filetype.
> However i have problems even gettings to the validation as django
> keeps telling me that there's no object.
> When i don't use the validation part I can upload an image just fine.
> So the upload thing works.
>
> I just can't figure out how to pass on the file to the validation
> part.
> I have tried with several approaches I have found on the internet.
> Therefore i will list my view, model and the two form methods i have
> tried.
>
> first, my view:
>
> def upload_file(request):
>         myprofile = request.user.get_profile()
>         current = request.user
>         print "upload 1"
>         if request.method == 'POST':
>                 form = AvatarForm(request.POST, 
> request.FILES,instance=myprofile)
>                 print "upload 2"
>                 if form.is_valid():
> [...]
>
> model:
> class Avatar(models.Model):
>         user = models.ForeignKey(User,unique=True,editable=False)
>         photo = models.ImageField(upload_to=get_profile_path, blank=True,
> null=True)
>         thumbnail = models.ImageField(upload_to='profile_thumb', blank=True,
> null=True)
>
> form:
>
> class AvatarForm(ModelForm):
>
>         class Meta:
>                 model = Avatar
>
> #1
>
>         def clean(self,data,initial=None):
>                 content = super(ImageField, self).clean(self,data,initial)
>                 content_type = content.content_type.split('/')[0]
>                 if content_type in settings.CONTENT_TYPES:
>                         if content._size > settings.MAX_UPLOAD_SIZE:
>                                 raise forms.ValidationError(_('Please keep 
> filesize under %s.
> Current filesize %s') % (filesizeformat(settings.MAX_UPLOAD_SIZE),
> filesizeformat(content._size)))
>                 else:
>                         raise forms.ValidationError(_('File type is not 
> supported'))
>                 return content
> #2
>         def clean(self):
>                 if 'photo' in self.cleaned_data:
>                         photo = self.cleaned_data['photo']
>                         print photo
>                         if photo.get('content-type') != 'image/jpeg':
>                                 msg = 'Only .ZIP archive files are allowed.'
>                                 raise forms.ValidationError(msg)
>                                 return photo
>
> The error i get is pretty much the same with both methods.  Nonetype
> has nu method/attribute: content_type/get... So i don't know if the
> rest of the validation code works since I can't pass my file through
> to the validation :-(
>
> Any help is appreciated :-)
>
> And a good weekend to all of you
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: testing validation of form in unit testing

2009-02-20 Thread Briel

You don't give a lot information about what is happening, so I'm
stabbing a bit in the dark here...

I would guess your problem is that you have created a form which has a
filefield that is required. Even though you probably upload a file and
maybe even pass it to the form, you are not doing it in a way that
django can understand. Probably because you choose to construct your
own date instead of using the data from request.POST and
request.FILES. It would be a much better approach to use the data from
request, and then if it needs to be altered, to do it in the form
validation. This could be done if you fx have a models primary key and
instead want to return the object.

Anyways, if this doesn't help you, you would help yourself a lot if
you do explain what exactly the problem is, what you are doing, maybe
a little snippet of code.

On Feb 20, 5:01 pm, Vitaly  wrote:
> Hi all
>
> I have a test that validate processed data to form with FileField. My
> steps in it direct me right to one problem. here is it.
>
> 'file' is 'Required field'
>
> What I do is process simple data right to form, not request.POST and
> request.FILES.
> I have tried process in data SimpleUploadedFile but no result.
>
> Why is it? and how this problem can be solved?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NoReverseMatch for a named URL

2009-02-20 Thread Briel

I've seen errors like this when an url is missing a view to link to.
All urls defined must have a view aswell. Start checking there else
look the problem could be that you are missing args for a url tag in
your template. Some reverse matching need args to fill in the dynamic
part of the url, like the pk of an object. That would be where I would
start looking.

On 20 Feb., 22:40, Philippe Clérié  wrote:
> I am working through the examples in Pratical Django Projects. I am
> using Django 1.02 on Ubuntu Intrepid. I expected to find problems
> because of version differences but in general I've been able to work
> out a solution. This one has got me stumped. You see the named url
> that is at fault is different depending on where it is placed in the
> project's urls.py.
>
> Presently it's like this and the coltrane_category_list is the first
> url in coltrane/urls/categories.py.
>
>     url(r'^blog/categories/', include('coltrane.urls.categories')),
>     url(r'^blog/links/', include('coltrane.urls.links')),
>     url(r'^blog/tags/', include('coltrane.urls.tags')),
>     url(r'^blog/', include('coltrane.urls.entries')),
>
> If I move the fourth line up, then the problematic url becomes the
> first one in coltrane/urls/entries.py.
>
> But I move the tags url (third from top) then they all work. Not for
> long though. As soon as I added the urls for the contrib/comments
> app, I got a problem again with a url in entries.py.
>
> As I said I'm stumped. Any help will be appreciated.
>
> I hope that was a clear description of the problem. Feel free to ask
> for more info.
>
> Thanks in advance.
>
> --
>
> Philippe
>
> --
> The trouble with common sense is that it is so uncommon.
> 
>
> 
> Request Method:GET
> Request URL:http://denebola.logisys.ht:8000/blog/
> Exception Type: TemplateSyntaxError
> Exception Value: Caught an exception while rendering: Reverse for
> 'cms.coltrane_category_list' with arguments '()' and keyword
> arguments '{}' not found.
>
> Original Traceback (most recent call last):
>   File "/var/lib/python-support/python2.5/django/template/debug.py",
> line 71, in render_node
>     result = node.render(context)
>   File "/var/lib/python-
> support/python2.5/django/template/defaulttags.py", line 378, in
> render
>     args=args, kwargs=kwargs)
>   File "/var/lib/python-
> support/python2.5/django/core/urlresolvers.py", line 254, in reverse
>     *args, **kwargs)))
>   File "/var/lib/python-
> support/python2.5/django/core/urlresolvers.py", line 243, in reverse
>     "arguments '%s' not found." % (lookup_view, args, kwargs))
> NoReverseMatch: Reverse for 'cms.coltrane_category_list' with
> arguments '()' and keyword arguments '{}' not found.
>
>   Exception Location:
> /var/lib/python-support/python2.5/django/template/debug.py in
> render_node, line 81
>   Python Executable:
> /usr/bin/python
>   Python Version:
> 2.5.2
>   Python Path:
> ['/home/philippe/prj/django/cms', '/home/philippe/prj/django',
> '/home/philippe/prj/django/cms', '/usr/lib/python2.5',
> '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk',
> '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-
> packages', '/usr/lib/python2.5/site-packages', '/var/lib/python-
> support/python2.5']
>   Server time:
> Fri, 20 Feb 2009 16:23:46 -0500
> 
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: file validation in admin form

2009-02-20 Thread Briel

Validation is a big subject, and the validation of files can be very
complex aswell. Anyways to validate you need to define a clean method
in your form. Here you put the code that can test things like file
types, and whatever you can think of using python. I can't get you the
link as I'm not at my laptop, but if you search the django docs for
"form validation" "clean" or "cleaned_data" you should be able to find
the right doc. You want to read about the clean method an is_valid().

On 20 Feb., 22:09, Michael Repucci  wrote:
> I'm totally new to Django and authorized/secure web apps, and really
> loving it for this. But I've got a few really novice questions. I've
> got a model with a FileField, to which users can upload an arbitrary
> file. In the model docs for the FileField it says, "Validate all
> uploaded files." And I'm not sure where to do this or how. Is this
> through the save_model method of the ModelAdmin class? If so, what is
> the basic format, because not executing obj.save() didn't seem to do
> the trick.
>
> Also, as mentioned in the docs, I don't want to allow a user to upload
> a PHP script or similar, and execute it by visiting the link, but I
> would like users to be able to place any of various file types on the
> server so that other users can download them. Is it enough to just
> exclude files with certain extensions (e.g., PHP, CGI, etc.), and if
> so, is there a list of all the "dangerous" file extensions somewhere?
>
> Thanks for your help 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner URL question.

2009-02-20 Thread Briel

I would sugest that you look at named urls and the {% url %} template
tag. That way you can generate urls with the use of args for year,
month, date.

On 20 Feb., 21:30, JoeG  wrote:
> I've tried to find this on Google but I don't know the terminology so
> I don't know what to search for.  It's more of an html question than a
> Django one but since I'm trying to learn Django, I thought I'd give
> this group a try.
>
> I'm developing a fiscal calendar application.  The URL will 
> behttp://host/calendar_id/fiscal_year/fiscal_month/day
>
> The URL starts with just the year and appends the period and day as
> you drill into the calendar.  Here's and example to illustrate;
>
>    http://localhost:8000/calview/1/2009          - Show the 2009
> fiscal year for calendar 1
>    http://localhost:8000/calview/1/2009/02     - Show the second
> period for FY 2009, calendar 1
>    http://localhost:8000/calview/1/2009/02/20 - Show the 20th day of
> the second period for the above
>
> I'm having trouble figuring out how to do the href.  On the first page
> above that shows the entire year, When I try to add on the period with
> and href "02", the url becomes "http://localhost:8000/
> calview/1/02" instead of "http://localhost:8000/calview/1/2009/02";.
>
> If I end the top URL with a slash, it works correctly but without that
> slash on the end, it replaces the year portion with the period instead
> of appending the period to the end.
>
> I realize that I could put in the full URL but that seems like it
> would be less flexible. I could also try and force the URL to always
> end in a slash but I'm not sure how to go about that.  Is there any
> way to build a relative URL that appends onto the end of the URL in
> the address bar without needing to have a backslash as the last
> character?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Managing over 100 static booleanfield fields Model, Form Class and so on. Profiles process

2009-02-25 Thread Briel

It's really not a good practice to ask 190 yes/no questions upon
registration. A lot of the answers will most likely be random as very
few would want to spend time answering 190 questions to complete a
registration. My advice would be to not have that many fields.

On 25 Feb., 13:02, NoviceSortOf  wrote:
> We have over 100 Yes/No questions asked in our registration process
> These questions are mostly static (requiring minor modification every
> 5-10 years),
> we don't especially need a dynamic data driven solution.
>
> These Yes/No questions are basically the user informing us of their
> specific
> interests IE. Archeology [ ], Poetry [ ], Art [ ] and so on.
>
> In our legacy client-side application (we are coming from a mailorder
> business started
> in the 60s) we store these selections in an abbreviated comma
> delimited character field ie
> Interests = "Arc,Art,Lit". Using a comma-delimited char field in this
> situation provides elegance on the data side, but of course we have to
> parse the field coming and going in order to make it usable also
> linking it to table that provides more human readable labels for the
> abbreviations.
>
> I'm considering simply adding the 190 odd boolean fields to accomplish
> this in profiles.models and the subsequent class needed in
> profiles.views to add presentable labels --- but am wondering if more
> of a data driven method may exist somewhere to
> accomplish this, perhaps using a comma delimited char field?
>
> Or how are such large amounts of yes/no boolean questions made
> manageable in Django?
>
> Any suggestion appreciated.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Fwd: python sql query in django

2009-02-25 Thread Briel

You have two choices. Either you can add .exclude() using the __in to
avoid get the duplicates in the first place. Or you could iterate over
the 3 pubs and append them to a list with an if statement. Something
like this:
list = []
for pub in publications123:
If pub not in list:
list.append(pub)

On 25 Feb., 21:54, Jesse  wrote:
> > I believe this would work:
>
> > publications = Publication.objects.filter(techpubcombo__technology=t)
>
> > Regards,
>
> > --
> > Christian Joergensenhttp://www.technobabble.dk
>
> Hello Christian,
>
> Thank you so much for your answer.  I have been struggling with the
> users group to get that syntax (I must not have been explaining it
> well enough).  Now I need the syntax for the next step, which I'm
> hoping you can help with.
>
> I have three statements:
> publications = Publication.objects.filter(techpubcombo__technology=t)
> publications2 = Publication.objects.filter(pathpubcombo__pathology=p)
> publications3 = Publication.objects.filter(commpubcombo__commodity=c)
>
> I need to combine the three sets into one set to eliminate duplication
> in the publications and then output the final set to the template.
>
> Thanks for any help!
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



{% trans %} and {% blocktrans %} breaking auto escape

2009-02-26 Thread Briel

I stumbled upon this by accident, and after doing some research on the
docs, it seems that there is a flaw with the translation template tags
and the auto escaping. I might have missed something or maybe it's
created to do this, so I'm posting here to figure out what's going on.

Anyways, the issue is that if I were to put {{ myvar }}, a user
submitted variable, it will auto escaped so that harmful text like <>
" ect will be escaped. However, if I put my var into a translation tag
like

{% trans myvar %} or
{% blocktrans %} this is {{ myvar }}{% endblocktrans %}

myvar will no longer be escaped, instead if a user would write some
harmful js/html code, it would be run. I found that if you put the
variables in blocktrans using with, it will be escaped:

{% blocktrans with myvar as myvar %}this is {{ myvar }}{%
endblocktrans %}

I found this behavior a bit odd, but I might have missed something, so
hoping some of you guys can help me clear up the use of the
translation tags without making a site unsafe.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: {% trans %} and {% blocktrans %} breaking auto escape

2009-02-26 Thread Briel

I have created a new ticket for this issue for those interested.
The ticket number is #10369

On 27 Feb., 03:36, Malcolm Tredinnick 
wrote:
> On Thu, 2009-02-26 at 01:11 -0800, Briel wrote:
> > I stumbled upon this by accident, and after doing some research on the
> > docs, it seems that there is a flaw with the translation template tags
> > and the auto escaping. I might have missed something or maybe it's
> > created to do this, so I'm posting here to figure out what's going on.
>
> > Anyways, the issue is that if I were to put {{ myvar }}, a user
> > submitted variable, it will auto escaped so that harmful text like <>
> > " ect will be escaped. However, if I put my var into a translation tag
> > like
>
> > {% trans myvar %} or
> > {% blocktrans %} this is {{ myvar }}{% endblocktrans %}
>
> > myvar will no longer be escaped, instead if a user would write some
> > harmful js/html code, it would be run. I found that if you put the
> > variables in blocktrans using with, it will be escaped:
>
> > {% blocktrans with myvar as myvar %}this is {{ myvar }}{%
> > endblocktrans %}
>
> > I found this behavior a bit odd, but I might have missed something, so
> > hoping some of you guys can help me clear up the use of the
> > translation tags without making a site unsafe.
>
> Nice catch. These both look like bugs. If you could open a ticket for
> them (put it in the internationalization category), they should be
> fixed.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: AttributeError: 'str' object has no attribute '_default_manager' from related.py django 1.0.2

2009-03-02 Thread Briel

Hi

You really dont make it easy for others to help you out. It would be
great if post info like, when the problem occurs like only specific
urls and just post the relevant info instead of posting a huge wall of
text that makes it a lot harder to find out where the problem is. Also
using something like dpaste.com really helps out aswell. Now I didn't
carefully read through all of the code, so I might be wrong here, but
it seems like your problem is in the last part

def formfield(self, **kwargs):
defaults = {
'form_class': forms.ModelChoiceField,
'queryset': self.rel.to._default_manager.complex_filter(
 
self.rel.limit_choices_to),
'to_field_name': self.rel.field_name,
}
defaults.update(kwargs)
return super(ForeignKey, self).formfield(**defaults)


File "/usr/lib/python2.5/site-packages/django/db/models/fields/
related.py", line 694, in formfield
'queryset': self.rel.to._default_manager.complex_filter(

AttributeError: 'str' object has no attribute '_default_manager'

It looks like self.rel.to in your error case returns a string, which
doesn't have the attribute _default_manager that you are calling on
it. Why this happens and how to fix it I can't say.

~ Briel


On 2 Mar., 17:11, Dan  wrote:
> AttributeError: 'str' object has no attribute '_default_manager' from
> related.py django 1.0.2
> ---get this error when
> accessing any part of site
> -
> MOD_PYTHON ERROR
>
> ProcessId:      2637
> Interpreter:    'TS1.unassigned-domain'
>
> ServerName:     'TS1.unassigned-domain'
> DocumentRoot:   '/var/www/'
>
> URI:            '/sipprovision/admin'
> Location:       '/sipprovision/'
> Directory:      None
> Filename:       '/var/www/sipprovision/admin'
> PathInfo:       ''
>
> Phase:          'PythonHandler'
> Handler:        'django.core.handlers.modpython'
>
> Traceback (most recent call last):
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1537, in HandlerDispatch
>     default=default_handler, arg=req, silent=hlist.silent)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1229, in _process_target
>     result = _execute_target(config, req, object, arg)
>
>   File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
> 1128, in _execute_target
>     result = object(arg)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 228, in handler
>     return ModPythonHandler()(req)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> modpython.py", line 201, in __call__
>     response = self.get_response(request)
>
>   File "/usr/lib/python2.5/site-packages/django/core/handlers/
> base.py", line 67, in get_response
>     response = middleware_method(request)
>
>   File "/usr/lib/python2.5/site-packages/django/middleware/common.py",
> line 56, in process_request
>     if (not _is_valid_path(request.path_info) and
>
>   File "/usr/lib/python2.5/site-packages/django/middleware/common.py",
> line 142, in _is_valid_path
>     urlresolvers.resolve(path)
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 246, in resolve
>     return get_resolver(urlconf).resolve(path)
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 179, in resolve
>     for pattern in self.urlconf_module.urlpatterns:
>
>   File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
> line 198, in _get_urlconf_module
>     self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])
>
>   File "/var/www/sipprovision/urls.py", line 2, in 
>     from extensions.models import Extension
>
>   File "/var/www/sipprovision/extensions/models.py", line 42, in
> 
>     class ExtensionForm(ModelForm):
>
>   File "/usr/lib/python2.5/site-packages/django/forms/models.py", line
> 195, in __new__
>     opts.exclude, formfield_callback)
>
>   File "/usr/lib/python2.5/site-packages/django/forms/models.py", line
> 162, in fields_for_model
>     formfield = formfield_callback(f)
>
>   File "/usr/lib/python2.5/site-packages/django/forms/models.py", line
> 177, in 
>     lambda f: f.formfield())
>
>   File "/usr/lib/python2.5/site-packages/django/db/models/fields/
> related.py&qu

Re: Location of files that are part of my application

2009-03-03 Thread Briel

Django makes python aware of your app folder when you install the app
so you can just do:

from appname.resources.filename import function

That should work whenever your app is propperly installed.

On 3 Mar., 21:41, Jack Orenstein  wrote:
> I have a small number of files that need to be accessible to my  
> Django application. These are part of the application, and so should  
> be treated as source code. The question is where to put them? Putting  
> them under MEDIA_ROOT doesn't seem right. They go with the  
> application so they should be somewhere under the application  
> directory. Suppose I put them in APPLICATION_NAME/resources -- how  
> would I then refer to these files? I obviously don't want to code an  
> absolute path into my application.
>
> Jack
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Inserting Into Cleaned_Data Inside a ModelForm

2009-03-07 Thread Briel

When using a modelform there are some ways to get you where you want.
You can get your form using request.POST. If it validates you can save
it like this creating a model.

record = form.save(commit=false)
record.key = 123
record.save()

Now, I cant remember but I believe that if you add missing key data in
cleaned method, giving the name django would expect, you would be able
to just save the form. You could also just manually access the key
field from the cleaned_data and apply it on the model.


On 7 Mar., 18:13, Chris Spencer  wrote:
> On Fri, Mar 6, 2009 at 12:57 PM, rajeesh  wrote:
>
> > You may change the save_model() method of corresponding AdminClass for
> > that:
> > e.g, to set the attribute 'a' of model 'Book' , write inside
> > BookAdmin.save_model() something like this:
>
> > obj.a = form.cleaned_data['another_key'] * 2
> > obj.save()
>
> Won't this only effect admin? I'm looking for a general solution that
> I can work into any form.
>
> Chris
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: I can't decide on a migration framework

2009-03-07 Thread Briel

A fixed migration is the code run to get from one step to another.
Migrations uses the, maybe at some point you needed to add an extra
table to the db. Then you could write a migration that would add the
table if you wanted to progress or delete the table if you wanted to
get back. You would have that list with app and when you install the
app elsewhere you could choose at which point in the migration history
you wanted your database in. Maybe for some testing you needed the
database like it was at some point. Evolution works differently, it
looks at the db and compares it to the models and the try to make the
changes needed when you run syncdb. So in order to controll evolutions
you would need to change to model fields.

On 7 Mar., 23:59, Ben Davis  wrote:
> I've been looking into both the "South" and "django-evolution" migration
> frameworks.   There are things I like about both of them, although I'm
> leaning towards django-evolution.
>
> The thing I like about django-evolution is that migrations are described in
> the same "language" as your model,  that is,  instead of adding/removing
> tables & columns,  we're adding/removing models and fields,  which is (I
> believe) the way it should be.  I don't feel like "create_table()" is any
> different from SQL's  "CREATE TABLE".
>
> However,  the author of South
> claimsto have started the
> project out of frustrations with django-evolution.  I've
> read those points, and having a really difficult time understanding what
> they really mean.  What do they mean by migartions not being "fixed in the
> codebase",  and "fixed migrations are all run when an app is first
> installed" ?   What exactly are "fixed migrations" anyways?   I'd love to
> understand these points as I don't want to regret choosing django-evolution.
>
> I haven't looked into dmigrations that much, but if anyone has any input on
> that I'm all ears.
>
>  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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: a little help on creating a 'global' file

2009-03-09 Thread Briel

Hi and welcome to django.

In regards to question 1, it looks like you are missing something. The
request object, that you have as parameter in your function, is used
in the views.py file. The object has a lot of the info that you need,
like the user, the post data if any ect. If you want to make a
functions like the one above, you dont need the request object in it,
as you dont use it in the function and isn't required.
I'm not sure what you mean with getting the output as html. Once you
get it to a template, it wont matter how it got generated, as long as
you dont escape the html chars.

If you want to import fx all functions in a fille, you can do it in
different ways.
You could do:
from myproject.globalValues import *
This would give you the functions like the ocultarEstado in the global
namespace, so you could call it by typing ocultarEstado(...). Another
way to import would be to do,
from myproject import globalValues as global
this would give you all the functions in the globalValues file on
"global", so you could do, global.ocultarEstado(...). You could change
the name after "as" into anything you like.

~Briel

On 9 Mar., 17:11, Julián C. Pérez  wrote:
> hi everyone from colimbia
> i'm new on django... so far, i love it... i'm very used to php, but
> the solution with django/python is just awesome
> i have started a project and i've been catching up with the basics...
> right now i have 2 doubts...
>
> 1. i created a file called 'globalValues.py' in the root folder of my
> project... the purpose?? to put in there all python functions created
> by me and called frequently among the code, and also to put some html
> 'shortcuts' to common stuff...
> the code in that file so far is next:
> # --
> # start code globalValues.py
> def ocultarEstado(request):
>         return { 'ocultarEstado' : 'hi u user!' }
> # end code
> # --
> very short right now jeje
> my question about it: how can i make 'ocultarEstado' function to
> output the string as html, instead of its raw representation??
>
> 2. said all above, in my 'settings.py' file there is the import as it
> follows:
> # --
> TEMPLATE_CONTEXT_PROCESSORS = (
>         'django.core.context_processors.auth',
>         'django.core.context_processors.debug',
>         'django.core.context_processors.i18n',
>         'django.core.context_processors.media',
>         'myproject.globalValues.ocultarEstado',
> )
> # --
> my question here: how can i import all functions inside 'globalValues'
> file with one call?? -i'm looking for a "myproject.globalValues.*"
> kind of expression"- making every function calling with an entry is
> quite large...
>
> thank u all!
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overlapping date range test

2009-03-09 Thread Briel

You have a problem with your calculation, if you dont want any overlap
at all.
The above code will only be true when the intire range of start/end 2
is within start/end 1.
what you need to check if you dont want any overlap is these two
statements:
(start1 <= start2 and end1 >= start2)
(start1 <= endt2 and end1 >= end2)

Basically what you need to check for is if either start or end date is
inside the start/end date range. If one of the dates is inside the
range, you will have partial overlap.

On 9 Mar., 16:28, gnijholt  wrote:
> Hello django-users,
>
> I'm having some trouble with a date-range filter.
> My goal is to prevent a model from being saved when it's date-range
> overlaps with existing records.
>
> Apparently, the math is quite straightforward:
>
> ( start1 <= end2 and start2 <= end1 )
>
> if TRUE, the ranges overlap (*)
>
> Still, I can't get it to work. Am I doing it wrong?
> I've tried some combinations, such as:
>
> SomeModel.objects.filter( Q(time_start__lte=self.time_end) & Q
> (time_end__gte=self.time_end)   ).count()
>
> Thanks for any help or hints.
>
> Gijs
>
> (*http://c2.com/cgi/wiki?TestIfDateRangesOverlap)
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Get Current User

2009-03-09 Thread Briel

You can get the current user through the request object: request.user.
If that fails, you need to have if you have AuthenticationMiddleware
installed probably.

~Briel

On 9 Mar., 17:48, Adam Schmitz  wrote:
> Hey All,
>
> I just setup my webapp to use the django user authentication and everything
> works smoothly so far. The one thing I'm wondering is: after the user logs
> in, how do you access the user object from another app?
>
> The main thing I'm trying to accomplish is I want to save a model with one
> of the fields being the current user that is logged in.
>
> --
> Adam
>
> "Say what you mean and mean what you say. Because those that matter don't
> mind and those that mind don't matter."
> -Dr. Suess
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: a little help on creating a 'global' file

2009-03-09 Thread Briel

The problem you are seeing regarding the link i mentioned briefly in
my last post. Django does auto escapingbe default of all template vars
and values. In your case that means that you see the html you wrote
because the <>" has been converted to a code that will display the
signs but disable the code. You can either use the |safe tag or stop
the auto escaping entirely for a part or the whole template. But you
need to be careful if you have user inputs on your site.

If you plan on using your global functions in the template only you
should considder creating your own template tags. That would also
solve any import problems.

You can read about both things in the django docs, can't give you the
links right now as I'm on mobile but search for template tags or auto
escape and you should hit some relevant stuff.

~Briel

On 9 Mar., 19:12, Julián C. Pérez  wrote:
> ok briel, maybe i should explain myself better
> you're right about the function with that innecesary 'request'
> object... but i'd need it for any other function -yet to be
> implemented
> -by the way, i use the shortcut render_to_response
>
> regarding the html stuff, with the function defined early if i make
> the call as:
> - in a html template...
> 
> ...
> {{ ocultarEstado }}
> ..
> 
> i get: 
> (aceptar)
> instead of a link: (aceptar)
>
> regarding the part of importing the functions...
> what i want is to import all the functions within that
> 'globalValues.py'
> actually i have only the import for the ocultarEstado method, done in
> the settings.py file with:
> ...
> TEMPLATE_CONTEXT_PROCESSORS = ( ...
> 'myproject.globalValues.ocultarEstado', ... )
> ...
> i mean, i don't want to import each new method like:
> ...
> TEMPLATE_CONTEXT_PROCESSORS = ( ...
> 'myproject.globalValues.function1',
> 'myproject.globalValues.function2',
> 'myproject.globalValues.function3', ... )
> ...
> but something like: 'myproject.globalValues.*'
>
> On 9 mar, 11:35, Briel  wrote:
>
> > Hi and welcome to django.
>
> > In regards to question 1, it looks like you are missing something. The
> > request object, that you have as parameter in your function, is used
> > in the views.py file. The object has a lot of the info that you need,
> > like the user, the post data if any ect. If you want to make a
> > functions like the one above, you dont need the request object in it,
> > as you dont use it in the function and isn't required.
> > I'm not sure what you mean with getting the output as html. Once you
> > get it to a template, it wont matter how it got generated, as long as
> > you dont escape the html chars.
>
> > If you want to import fx all functions in a fille, you can do it in
> > different ways.
> > You could do:
> > from myproject.globalValues import *
> > This would give you the functions like the ocultarEstado in the global
> > namespace, so you could call it by typing ocultarEstado(...). Another
> > way to import would be to do,
> > from myproject import globalValues as global
> > this would give you all the functions in the globalValues file on
> > "global", so you could do, global.ocultarEstado(...). You could change
> > the name after "as" into anything you like.
>
> > ~Briel
>
> > On 9 Mar., 17:11, Julián C. Pérez  wrote:
>
> > > hi everyone from colimbia
> > > i'm new on django... so far, i love it... i'm very used to php, but
> > > the solution with django/python is just awesome
> > > i have started a project and i've been catching up with the basics...
> > > right now i have 2 doubts...
>
> > > 1. i created a file called 'globalValues.py' in the root folder of my
> > > project... the purpose?? to put in there all python functions created
> > > by me and called frequently among the code, and also to put some html
> > > 'shortcuts' to common stuff...
> > > the code in that file so far is next:
> > > # --
> > > # start code globalValues.py
> > > def ocultarEstado(request):
> > >         return { 'ocultarEstado' : 'hi u user!' }
> > > # end code
> > > # --
> > > very short right now jeje
> > > my question about it: how can i make 'ocultarEstado' function to
> > > output the string as html, instead of its raw representation??
>
> > > 2. said all above, in my 'settings.py' file there is the import as it
> > > follows:
> > > # --
> > > TEMPLATE_CONTEX

Re: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread Briel

First of all what you have written will most likely give syntax error,
in your dict you have reversed the key and value. You probably want it
to look like this: {"username": thisusername}. But you can't just
throw random data at forms and hope for it to work. There are some
different solutions, but if all you want to dø is to write hallo
username, you dont even need to do anything with forms, unless you
want the username to be displayed in an input field when the form
loads. Remember, django forms are not forms, but form elements. You
still have to suply the form and input tags yourself and thus can
write hallo username or whatever inside the form if you want it as an
headline or something else.

~Jakob

On 16 Mar., 20:14, NoviceSortOf  wrote:
> Thanks for your responses, they have helped.
>
> I've read the documentation many times, and only resort to groups
> after re-reading what I can find in the docs, testing various logical
> solutions, digging through groups and finally confering with a 3rd
> party book I've here on Django. If all else fails,
> then I post to groups.
>
> So that is why I'm puzzled when {{ var }} does not present var on my
> form.
>
> As mentioned above in views.py I'm passing data to the form_class in
> this example I'm using str to convert value to string.
>
> in view.py then
> ...
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Now it seems form_class() would be adding the data to
> itself with form_class(data) but it isn't.
>
> Instead I have to add the context to the render_to_response
> despite the fact that this data has been added to form
> earlier.
>
> ie.
> return render_to_response(template_name, { 'form': form},
>                               context_instance=context)
>
> will either not display the item, or force it to be viewed
> only as a corresponding writable field as defined in forms.py
> or model.py.
>
> but loading it directly to render_to_response works...
>
> return render_to_response(template_name, { 'form': form,
> 'thisusername':username},
> context_instance=context)
>
> So perhaps a better question would be is
>
> in view.py...
> ---
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Why is it form_class(data) does not accept the data
> as declared and enable it to presented it in
> templates in any other form than a writable field
>  --  when render_to_response allows the data to be
>      presented as a string?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to get the root path ?

2009-03-18 Thread Briel

Hi.
Instead of generating all of your urls as a base url + something, you
can insteadl use the url template tag, that way you can get your url
in the template more or less like this (if you use named urls):
{% url user_change %}
using reverse matching, django can figure out what the url needs to
be, and if you deside to change your url mapping, all you need to do
is change your urls.py files to get the change. That way you wont have
to go through templates ect to make a lot of changes all over the
place.
You can read about the url template tag at the docs.
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url

~Jakob

On 18 Mar., 13:35, Bro  wrote:
> Hi,
>
> My project root path is :http://127.0.0.1:8000/
>
> The user path is :http://127.0.0.1:8000/user/
> The change form path is :http://127.0.0.1:8000/user/change/
> In the template.html file I use : {{ root_path }}change/
>
> My question : how to get the variable of the root path (http://
> 127.0.0.1:8000/)
> I want to have this url :http://127.0.0.1:8000/change/
>
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Prepopulate form from URL?

2009-03-18 Thread Briel

Hi.

When you setup urls, they can have dynamic parts in them, so you dont
need to use ?=, but could have an url foo/bar where your url would
grab the bar and turn it into a variable. Fx if you had an url like
this in your urls.py:
(r'^foo/(?P\w+)/$', 'my_view_name')
bar would become my_var, that you could use in your view. You can
change the reg match to fit your needs. Then all you would need to do,
would be to create the form with the data collected from the url and
render it to a template for display.
You can read about the how django work with urls in the docs:
http://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-urls

~Jakob

On 18 Mar., 15:06, Jorge Romo  wrote:
> Hello!
>
> I was trying to see if there's a way (I'm pretty sure there is a way)
> to prepopulate a form field from an url. For example: /foo?=bar and
> that in my form field "bar" is displayed. I have to work with java?
> there is another 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: yet another unicode question...

2009-03-18 Thread Briel

Hi.
I'm not sure what exactly you are doing and how/where you are
displaying this stuff. But it sounds like you are escaping the html,
django does this by default to protect sites from XSS attacks ect. You
can either stop the auto escaping in the template or use the |safe
tag. You can read about django auto escaping in the docs at:
http://docs.djangoproject.com/en/dev/topics/templates/#id2

~Jakob

On 18 Mar., 16:32, Juan Hernandez  wrote:
> Hi there,
>
> This has been killing me for hours and I don't know what else to do. Is
> about the famous charset in django.
>
> I have this model:
>
> class Post(models.Model):
>     user = models.ForeignKey(User)
>     category = models.ForeignKey(Categories)
>     title = models.CharField(max_length=50)
>     post = models.CharField(max_length=1)
>     date = models.DateTimeField(auto_now_add=True)
>
>     def __unicode__(self):
>         return u%s %s %s %s %s(self.user, self.category, self.title,
> self.post, self.date)
>
> with this information on the database:
>
> mysql> select * from blog_post;
> ++-+-+--+
> +-+
> | id | user_id | category_id | title            |
> post                                                                  |
> date                |
> ++-+-+--+
> +-+
> |  8 |       1 |           2 | html Aqui | asdfasd
> sdfsdfsd | 2009-03-18 01:27:49 |
> ++-+-+--+
> +-+
> 8 rows in set (0.00 sec)
>
> and the post column is being rendered on django html like this:
>
> asdfasd sdfsdfsd
>
> What is going on? I have changed the CHARACTER_SET in settings.py and
> followed many things on different threats with no success at all
>
> Everything on the DB is utf8 and I also have DEFAULT_CHARSET = 'utf8' at
> settings.py
>
> How can I have django display html code from the databse without any
> problems?
>
> Thanks a lot
> Juan
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django choises field

2009-03-18 Thread Briel

Hi.
I dont think you can get user input pn a field with choices, but then
you dont really need choices if you want users to be able to input
anything. Choices are used when you only want to accept certain values
like a list of countries, states, or whatever.
It doesn't seem like you have thought through what should happen if a
user want to sellect other. A select list is a good choice for choices
but if you choose other then what? Do you want you select list to be
transformed to a textfield? Do you want an extra textfield to write
the other value? Or do you want to add an text field when you have
selected other.
There are many posibilities, some will need javascript, but I think
you need to figure out how you want things to happen. Then you
probably can find the best solution, maybe something else than
choices.

On 18 Mar., 21:45, Psihonavt  wrote:
> hello,
> have a question, in my model, i have filed, like:
>
>     cpu_ch =(
>         ("Box","Box import"),
>         ("EOM","EOM import"),
>     )
> import_type = models.CharField(_("Import type"), max_length=5,
> choices=cpu_ch, blank=True)
>
> I want to have a third choice in choices cpu_ch, for example, "other",
> and when I choose this option, then I should be able to enter there
> any string and save the filed with this value.
> ps. sorry for my english
>
> thnx
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Showing forms based on on selected fields

2009-03-20 Thread Briel

Hi.
If you want to do anything clientside, meaning you want to react on
input fields being selected or certain values being input ect you need
javascript. Django can only react on data being sent or urls being
asked for, not what the user is typing.

Now it's not clear exactly you what it is you want to do. But it
sounds like you could do it quite easely with jQuery. You probably
want to show it all with out the js and then hide the parts you want
and only show them when certain conditions are met.

~Jakob

On 20 Mar., 18:09, DanielM  wrote:
> Hi there,
> i am trying to implement a contact form where some fields are shown by
> default and others shall be shown if some of default is selected. What
> my options of implementing this feature would be?
>
> 1. Javascript into the template - but then how would i change the
> shown template if anything is selected?
> 2. Can i go over submitted values and if some_field_is_selected throw
> a template with additional form?
>
> Seems to be easy to do but no easy solution.
> Please send me some links of possible.
>
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: clean data

2009-03-23 Thread Briel

Hi
I'll try to help answer your 3 Qs

> 1.  what does cleaning actually do... prevent sql query injections?
> Anything else?

Cleaning data is not in place as a security measure, but rather to
help you validate the data. That means that you can check the data
and find out if it fill your requirements. If you have a text field
and
want users to type in a serial number, you probably need some
custom validation like to see if the serial number has the correct
number of digits/chars ect. Or if they need to type in a phone number
you probably want to check that as well. Django does some validation
for you automatically, like checking email fields for @ and dots.

> 2.  I'm assuming, if I had a function as follows:
>
>     def clean(self):
>         cleaned_data = self.cleaned_data
>         return cleaned_data
>
> That this would return a dictionary of  the form in it's cleaned
> state.  Is this a correct assumption?

The above method wouldn't actually do anything AFAIK as by
default django forms will have their cleaned data in a dictionary.
You actually don't need to write a clean method unless you need
to do custom/special validation. Like checking date inputs in a
textfield.

> 3.  How would I call this when saving data?  Lets say I have this in
> my view which saves the data to the database:
>
>                         mydata=Mydata(
>                                 
> description=request.POST.get('description',''),
>                                 sku = request.POST.get('sku',''),
>                         mydata.save()
>
> is it as simple as wrapping the request.POST.get... in clean()?

The cleaned_data is available to your form, so if you have a form
called MyForm, that you have imported in your view and are
rendering in your template. You could then do something like this:

form = MyForm(request.POST)
if form.is_valid():
sku = form.cleaned_date['sku']


If you are saving a model, you should look at ModelForms, where
you can save the form to create a new instance of the model.

~Jakob


--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: need a multiselect list box for a static list of options

2009-03-23 Thread Briel

Hi.

I haven't played much around with this kind of thing, but I
would suggest that you take a look at the form widgets.
One of them is called, SelectMultiple, which I bet is the one
you are after, but I'm not sure if it will work with choices.
You can find something about it at
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

~Jakob

On 23 Mar., 19:49, Adam Fraser  wrote:
> Hello,
>
> This should be a pretty simple question.  I have a list of options:
>
> STAIN_CHOICES = (
>     (1, 'DNA - DAPI'),
>     (2, 'DNA - Hoechst'),
>     (3, 'DNA - other'),
>     (4, 'Actin - Phalloidin'),
>     (5, 'Tubulin'),
> )
>
> I would like users to be able to select more than one of these things
> at a time.  It looks like models.CommaSeparatedIntegerField would be
> good for this, but how can I get a multi-selection list box as an
> input?
>
> -adam
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: clean data

2009-03-23 Thread Briel

I'm not sure how django has built it sql injection protection, but I
would guess that when you fx do model.save() or form.save()
that the functions actually making the sql to the db makes sure
that there are no injections by making place holders for data ect.

XSS is something I do know how work, however, and is not
in effect when data is being saved, but rather when it is being
rendered. Django will auto escape all potentially harmful chars
like < > ", to prevent anything such attacks.

~Jakob

On 23 Mar., 20:31, Bobby Roberts  wrote:
> > Cleaning data is not in place as a security measure, but rather to
> > help you validate the data. That means that you can check the data
> > and find out if it fill your requirements. If you have a text field
> > and
> > want users to type in a serial number, you probably need some
> > custom validation like to see if the serial number has the correct
> > number of digits/chars ect. Or if they need to type in a phone number
> > you probably want to check that as well. Django does some validation
> > for you automatically, like checking email fields for @ and dots.
>
> I thought I read that there was a way to chk data for sql query
> injections / cross site scripting etc before insertion Is that a
> mis-understanding on my part?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: html greater than less than encoding problem

2009-03-23 Thread Briel

Hi.

It sounds like you have run into the auto escape filter. It basically
converts html tags into something viewable but not html. This is
a protective matter, to protect your site from cross site scripting
attacks, that can take down your site and worse. If you want to
display some html from your db that you know are "safe", you can
use the |safe tag to tell django not to escape it. Read about it at
the
docs.

http://docs.djangoproject.com/en/dev/topics/templates/#id2

~Jakob

On 23 Mar., 21:16, gl330k  wrote:
> Hi all,
>
> I'm a django newbie. I have a mysql database backend and when I try to
> output html from the database I'm getting all the html as
>
> ampersand + l + t + ;
>
> So then when I view the page I'm basically seeing all the html tags.
>
> mysql server - 5.1.30
>
> Thoughts?
>
> What am I doing wrong?
>
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why save on attributes is no good?

2009-03-24 Thread Briel

Hi

I'm not sure exactly how this work, but.
Your problem is how the data is saved and retrieved.If you do
self.sm_id
after the save(), you will get the id by reference, but when the model
itself needs to be saved, it need the data itself, which it hasn't, or
something like that

Anyways, to get it to work you need to do it like this:

> self.sm = SomeModel()
> self.sm.save()
self.sm = self.sm
self.save()

~Jakob
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to show the links to tell website visitor which location he is at in django?

2009-03-26 Thread Briel

What you are asking for is called breadcrumbs. You can search google
for django + breadcrumbs to find stuff about it and what others have
done. One way of doing it, is explained in this blog post, it's both
simple and well explained. If this is the best way, i do not know, but
at least it'll get you started.

http://www.martin-geber.com/thought/2007/10/25/breadcrumbs-django-templates/

~Jakob

On 26 Mar., 14:04, xiaojay  wrote:
> sorry to the English I speak. I am not an native English speaker.
>
> suppose my sitemap is something like below;
>
> /home
>         /home/products/
>               /home/products/1
>               /home/products/2
>                .
>                .
>                .
>         /home/news/
>                /home/news/1
>                .
>                .
>                .
>        /home/login/
>        /home/logout/
>                .
>                .
>                .
> when a website visitor browser any page, I want on the page the right
> up corner contain  links show where he is. eg: when he browser the
> page /home/product/1, I want the link will be "/home/product/
> product_name" and "home" is a link to home page ... etc
>
> I know the way putting some judgging code in every view, but is there
> a better way in django?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Template - Deleting last character in loop

2009-03-26 Thread Briel

You can add an if statement and check if
{{ foo|lenght }}  and  {{ forloop.counter }} matches to find out
when you have reached the end of the loop.

~Jakob

On 26 Mar., 14:46, Kless  wrote:
> I'm building a dinamic list of links, and I want that been separated
> by '|' character.
>
> Note that 'foo' is a list
> ---
> {% for i in foo %}
>         {{ i }}|
> {% endfor %}
> ---
> The problem is that I wantn't that last separator (because there isn't
> another field).
>
> I tried the next one but without luck:
> ---
>         {% ifnotequal i foo|slice:'-1' %}|{% endifnotequal %}
> ---
>
> How could be solved?
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Admin Question

2009-03-26 Thread Briel

You can use 'list_filter' in admin.py to add which filters you want to
set.
so if you have a status reviewed/await review you can use that.
You can also use 'search_fields' if you want to do some searching.
Lastly you can use 'ordering' as well if you prefer. I would sugest
you
try to play around with it and figure out what suits you best.

~Jakob.


On 26 Mar., 15:43, Wiiboy  wrote:
> Sorry, I wasn't very clear.  The Administration's purpose is to let me
> decide, from the submissions that are pending review, which ones I
> want to accept (change the value for the column 'status' to 'accepted'
> for that row) and which ones I want to not accept (change the value
> for the column 'status' to 'unaccepted' for that row)
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unit tests with live data from database.

2009-03-26 Thread Briel

Hi.

Fixtures doesn't need to be 'fixed'. You can create some fresh
fixtures with
a db dump. However, your code shouldn't break by changing an entry,
changing tables ect, might give problems, but that shouldn't be
something
you do everyday on a production site anyways. That said, some problems
will only show in some cases, and it's impossible to test for every
case, as
you probably will miss some special cases anyways.
The key to making good tests is not only the tests themselves, but
also
having a good data set to use for the testing.

So I guess the quick answer, is to simply make a db dump
and use that for testing. It should be fairly easy to create a new
fixture and
if needed you can make a new dump every day/week.

~Jakob

On 26 Mar., 21:35, MikeL  wrote:
> I've noticed that the "/manage.py test" script creates a temporary
> database and requires fixtures to populate data for testing. But what
> about when tests involving large amounts of data that can be changed
> and we need to test our views by using that data? If someone
> accidentally breaks a view by just changing an entry in a database how
> can we test for this? If we just use fixtures, then the test data will
> always be valid.
>
> I guess what we need to know is, can we setup the testing to use the
> live database (May have to disable fixtures for instance)? Also if we
> do that, can we prevent the changes made from unit tests from being
> permanent (create user account each time for example)?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.user in forms.py

2009-03-26 Thread Briel

Hi.
You are on the wrong track trying to do it with request.user. The
problem is that when you create the form, there is no request
object with associated user. You need to do your stuff in the
__init__.py instead, where you can create a custom, using
the user object as an extra variable.

I got a link to a blog post describing how to do it, so I would
suggest that you take a look at it and try to use the method.

http://collingrady.wordpress.com/2008/07/24/useful-form-tricks-in-django/

~Jakob

On 26 Mar., 19:37, Konstantin S  wrote:
> Hello!
>
> I know this a very stupid question but nevertheless how can I get
> request.user object in forms.py file ? I am trying  to do something
> like:
>
> class ItemGetForm(forms.Form):
>     box = forms.ModelMultipleChoiceField(
>         queryset=Box.objects.filter(owner=request.user),
>         widget=forms.RadioSelect)
>     label = forms.IntegerField()
>
> Where:
>
> class Box(models.Model):
>     owner = models.ForeignKey(User)
>     description = models.CharField(max_length=500, blank=True, null=True)
>
>     def __unicode__(self):
>         return self.description
>
> But constantly get an error 'Caught an exception while rendering: name
> 'request' is not defined'.
>
> If am completely wrong here what is a preferable way of doing such things ?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I define choices in ChoiceField

2009-03-27 Thread Briel

Hi.
Choices is a tuple/list of tuples/lists, so in your case it would look
like this:
(('one', 'one'), ('two', 'two'))
You can't use dictionaries.

~Jakob

On 27 Mar., 14:43, Joshua Partogi  wrote:
> Hi all,
>
> Let me just get straight to the point
> I tried these:
> label = forms.ChoiceField(choices=({'one':'one','two':'two'}) )
>
> And received these:
> Exception Type:         TemplateSyntaxError
> Exception Value:        Caught an exception while rendering: too many values 
> to unpack
>
> What was wrong with my code? Does anybody know how should I define the 
> choices?
>
> Thank you very much in advance
>
> --
> If you can't believe in God the chances are your God is too small.
>
> Read my blog:http://joshuajava.wordpress.com/
> Follow me on twitter:http://twitter.com/jpartogi
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Confused by attribute error

2009-03-27 Thread Briel

Hi.
It would be really helpful to be able to look at your function as
well. My
Guess is that the problem lies there, since this is happening when you
call the function. Even if the problem is within django it would be a
lot
easier to find when looking through your function to see what it does.
Also please post it at dphaste or some other simelar website.

~Jakob

On 27 Mar., 22:52, Robocop  wrote:
> Hello again,
> So i'm working on some of my old code, and a previously (or so i
> remember) function no longer works.  When calling it my django page
> posts the error:
>
> AttributeError at /audit_sheets/TEST/
>
> 'list' object has no attribute 'user'
> Request Method:         POST
> Request URL:    http://support.mipscomputation.com/audit_sheets/TEST/
> Exception Type:         AttributeError
> Exception Value:
>
> 'list' object has no attribute 'user'
>
> Exception Location:     /usr/local/lib/python2.4/site-packages/django/
> contrib/auth/decorators.py in __call__, line 66
> Python Executable:      /usr/local/bin/python
> Python Version:         2.4.3
> Python Path:    ['/home/mipscomp/public_html/support', '/home/mipscomp/
> public_html/support', '/usr/local/lib/python2.4/site-packages/
> MySQL_python-1.2.2-py2.4-linux-i686.egg', '/usr/local/lib/python2.4/
> site-packages/flup-1.0.1-py2.4.egg', '/usr/local/lib/python2.4/site-
> packages/python_memcached-1.43-py2.4.egg', '/usr/local/lib/python2.4/
> site-packages/pycrypto-2.0.1-py2.4-linux-i686.egg', '/usr/local/lib/
> python2.4/site-packages/Reportlab-2.1.0001-py2.5.egg', '/usr/local/lib/
> python2.4/site-packages/django_registration-0.7-py2.4.egg', '/usr/
> local/lib/python2.4/site-packages/elementtree-1.2.7_20070827_preview-
> py2.4.egg', '/usr/local/lib/python2.4/site-packages/docutils-0.5-
> py2.4.egg', '/usr/local/lib/python2.4/site-packages/setuptools-0.6c9-
> py2.4.egg', '/usr/local/lib/python24.zip', '/usr/local/lib/python2.4',
> '/usr/local/lib/python2.4/plat-linux2', '/usr/local/lib/python2.4/lib-
> tk', '/usr/local/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/
> site-packages', '/usr/local/lib/python2.4/site-packages/PIL']
> Server time:    Fri, 27 Mar 2009 16:46:47 -0500
>
> The line in question is:
>
> #  timesheet_export(timesheets,date)
>
> where timesheet_export is my special lil function, and timesheets is a
> list of objects.  Now the error seems to directly come from this:
>
> /usr/local/lib/python2.4/site-packages/django/contrib/auth/
> decorators.py in __call__
>
>   59. update_wrapper(self, view_func)
>   60.
>   61. def __get__(self, obj, cls=None):
>   62. view_func = self.view_func.__get__(obj, cls)
>   63. return _CheckLogin(view_func, self.test_func, self.login_url,
> self.redirect_field_name)
>   64.
>   65. def __call__(self, request, *args, **kwargs):
>
>   66. if self.test_func(request.user): ...
>
>   67. return self.view_func(request, *args, **kwargs)
>   68. path = urlquote(request.get_full_path())
>   69. tup = self.login_url, self.redirect_field_name, path
>   70. return HttpResponseRedirect('%s?%s=%s' % tup)
>
> And right now i'm not sure what the decorators.py file is trying to do
> with regards to my function.  Considering i've never explored the
> inner workings of decorators.py, i'm not sure exactly what it's doing
> in this instance.  All i know is it's looking for user attributes in a
> list of totally unrelated objects.  Any thoughts or ridicule are
> always appreciated!
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination

2009-03-30 Thread Briel

Hi
I haven't actually used django's own pagination, so I guess I can't
really compare. Though working with django-pagination is really
easy and it's well written. Made by the people that made pinax...

~Jakob

On 30 Mar., 12:36, Konstantin S  wrote:
> Hello!
>
> I noticed that there are two paginations 'engines' available for
> django. The first one is in django distribution itself
> (http://docs.djangoproject.com/en/1.0/topics/pagination/), and the
> second one I found at code.google.com. (Url 
> ishttp://code.google.com/p/django-pagination/). Which one would you
> recommend ?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: weird name error

2009-03-30 Thread Briel

Hi.
You really dont give much information, when this
happens traceback ect, but a wild guess would
be to check your imports.

~Jakob

On Mar 30, 7:04 pm, Adonis  wrote:
> Hello,
> You will love this one,
>
> models.py
> *
> class LayersOfUsers(models.Model):
>     name = models.CharField(max_length=50)
>     desc = models.TextField(null=True)
>     geouser = models.ForeignKey(User)
>
>     def __unicode__(self):
>         return self.name
>
> class Species_d(models.Model):
>     speciesName = models.CharField(max_length=200, null=True)
>     speciesUser = models.ForeignKey(User)
>     lon = models.FloatField(4)
>     lat = models.FloatField(4)
>     uLayer = models.ForeignKey(LayersOfUsers)
>
>     def __unicode__(self):
>         return self.speciesName
> *
>
> i am getting a name error on this occasion:
> * NameError: name 'LayersOfUsers' is not defined *
> Anyone care to suggest sth? I will also add a hint, because the
> initially created project is now running under mod python, this
> happens to be a newly created project but with copied-paisted code
> from the previous one, so that i can continue developing.
> Kind regards,
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle the Browser Close ?

2009-03-31 Thread Briel

Hi.
You don't really have to log the user out, unless you are making
something with very sensitive material. A lot of sites wont log you
out unless you haven't been at their site for some time.

One thing you could do, would be to log users out that haven't
been active for x minutes/hours, but you might log users out
that are still somewhat active on your site, but are gone for lunch
or are googling or just reading the same page for a long time

~Jakob

On 1 Apr., 08:26, veeravendhan  wrote:
> Say a user is logged in to the system,  If he closes the browser how
> will I handle the Logout for that user ? Any idea ??
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can I use Components and Classes in Django for views/controllers?

2009-04-01 Thread Briel

Hi.
For the second part, it looks like you could use your own
template_context_preprocessor. With it you can do stuff like
creating variables for your template. Maybe this would be able to
solve your problem having to send the same template vars over and
over again. If you dont need view specific variables, this should do
it.

You can take a look at the docs about them and how to write them:
http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors

~Jakob


On 1 Apr., 09:42, Ståle Undheim  wrote:
> I come from a Java background, and I really like Apache Wicket as a
> way for constructing web frameworks. In it you use classes, extension
> and compositions to build your pages. This allows for great reuse off
> components in different pages.
>
> Django however works via functions instead, which can't be extended.
> And since each function will represent a full page, they seem harder
> to combine together. Maybe the way I am thinking about how to solve
> stuff in Django is too much affected by my Java background, and I am
> not doing things in a Pythonic way.
>
> So I have 2 cases, I will explain the problem, how I would solve it in
> Wicket, how I have solved it in Python and the issues I have with the
> solutions. Maybe someone can give me some good pointers and advice
> regarding this.
>
> The first thing I have is a file list. I use this in 2 different
> places. The list has some filter checkboxes on top, and a table off
> files, each with a link next to them. In 1 view the link says "view"
> and takes you to viewing the file, in another view it adds the file to
> a selection off files. In Wicket I would make a file list component,
> this had 2 properties you needed to set, link text and onclick
> action.
>
> For Django I instead ended up just copying the template and fitting it
> for each case. Each view has a different base template they extend
> which is the context for the application. I also needed to make sure
> the context was correct in each view function. I used some javascript,
> and was able to copy that directly. I really don't like that I have to
> copy the template code around, and match up the view context to this
> template in each case. Is it possible to turn my file list into a
> component with just 1 template and some config, without it being
> excessively verbose?
>
> The other thing I have is multiple views in one app that use the same
> base design template. The base design template provides menus related
> to the app, while each view provides the content in the design. Since
> there is common context variables that are needed for the design
> template for each view, each view must include these variables in it's
> context for things to work. Which I again feel like is duplication off
> code. I would instead prefered a base class for the app, that all the
> views in it extended, and thus didn't need to worry about setting up
> the root context correctly.
>
> I hope someone can enlighten me about me either being all wrong in how
> I think about app construction, or that there are good elegant
> solutions for these things already available.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: JQuery magic in admin?

2009-04-02 Thread Briel

Hi,

If you don't need the form elements themselves, as you do everything
in the save method, you don't need to do anything with the form.
All you need to do, is to create the visual effect, which can be done
with jQuery quite easily. You could just hide the fields if you prefer
them
empty and create some of your own fields to display then stuff in, or
just
use the form fields.

I would suggest a blur trigger that check if values on the needed
fields
have been filled. Then all you need to to, is to make a ajax get
request
where you send along the values. Create a view that handles the calc
and sends the data back. You could also if you prefer do the
calculation
in javascript. But I don't see how this should break your setup.

~Jakob

On 2 Apr., 09:59, Alfonso  wrote:
> Hi,
>
> I've got two very unremarkable models, Invoice Order that has a
> foreign key to an Invoice model.  There are some tax calculations that
> happen on the save of the order model that populate and update the
> corresponding fields in the Invoice model.  All works fine and in fact
> all calculations in the system happen within a custom save function.
>
> So as far as the user is concerned they see a few fields that are
> empty but populated when the form is saved.  The client has requested
> to see if we can improve that functionality and populate the necessary
> fields as the user fills in the form, so once a price and tax rate are
> added the final price field is populated also.  Along with that the
> form will be populated with the relevent prices when a user selects
> the product to add to the order.  complicated I think.
>
> My question centers around how I would implement such functionality,
> it screams to me JQuery or similar doing it's magic to perform the
> necessary calcs and then django reverts to a normal save function.
>
> Obviously that is a pretty big rewrite and I'd like to avoid making
> things complicated and losing what coding I've done.
>
> Does anyone have any better suggestions for how I might accomplish
> that sort of functionality fairly cleanly?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do i use dojo in my Django application

2009-04-02 Thread Briel

Hi.

The docs explain in great detail how you can serve static files like
the
dojo library. Take a look at it here:
http://docs.djangoproject.com/en/dev/howto/static-files/

~Jakob

On 2 Apr., 14:50, Gath  wrote:
> All,
>
> I have downloaded Dojo 1.3, i want to start sampling some examples  in
> the Dojo website using Django, where do i place the package? How do i
> call it in my template?
>
> Gath
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django model problem

2009-04-03 Thread Briel

Hi.
A quick solution would be to add a datefield to the album
the release date. You could then use that to find the
latest and it would be updated automatically when
adding new albums. You could use ot for other things
as well, but I don't know your needs. Will also make the
lookup a bit slower but shouldn't be that bad.

~Jakob


On Apr 3, 10:14 pm, Albert  wrote:
> Hi,
>
> Say I have these simple models:
>
> class Musician(models.Model):
>     first_name = models.CharField(max_length=50)
>     last_name = models.CharField(max_length=50)
>
> class Album(models.Model):
>     artist = models.ForeignKey(Musician)
>     name = models.CharField(max_length=100)
>
> Now in `Musician` I want to add a field "last_album".
> How can I do that? I'd like to be able to write:
>
> m = Musician(pk=1)
> print m.last_album.name
>
> When I try:
>     last_album = models.OneToOneField(Album)
>
> it somehow works but creates a (useless) unique index for last_album.
> And I don't need additional related field in the Album model (it's
> also
> created now).
>
> Thanks for help!
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using variable attribute as attribute to another variable

2009-04-03 Thread Briel

Hi I don't believe you can use variables within variables. What you
can do is use/make a template tag that will look up in the list.
Or you could make if forloop.counter == statements.
Or you can make a dictionary and fx make the day_list keys
And the table_list values and iterate over the key, value pair

~Jakob

On Apr 4, 7:47 am, Travis  wrote:
> I am trying to use a 'dotted variable' (forloop.counter in this case)
> as an index to a list, but without success so far.
>
> I have a list of strings called 'table_string' and the following code:
> {% for d in day_list %}
>      {{d}}{{table_string.forloop.counter}}
> {% endfor %}
>
> What I'm trying to do is render the table_string item (indexed 1-7)
> for the appropriate day using the forloop.counter variable, but I am
> getting no result (or at least the TEMPLATE_STRING_IF_INVALID).
>
> Can someone please suggest what I need to do to use a variable
> attribute as the attribute to another variable?
>
> Travis
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Template Question

2009-04-06 Thread Briel

If you are trying to construct a "base" template for several views you
could
also use the {% if %} tags, and only show the relevant parts of the
page.
For example, if you wanted to display a table, but the number om
columns
would vary, this would enable you to only display the needed columns.

On a side note, you shouldn't be doing the logic in the template, and
when
needed pull in different stuff, do operations ect. Instead you should
use your
views for that, and keep the template for presentation. That's the way
django
is built and it would also make it a lot easier on your self and
others if you
keep logic and presentation separate.

~Jakob

On 6 Apr., 09:59, Daniel Roseman 
wrote:
> On Apr 6, 6:38 am, codingJoe  wrote:
>
>
>
> > Up front, I'm not the most elegant coder, so please forgive.
>
> >   I have a page that is produced using django templates.   I used the
> > templates to do the header and footer, but now I'm down into the body
> > of the page.   Using the data from my template, I am able to fill the
> > first cell.
>
> > Is is possible to have the template do a request/response for other
> > data?  Or do I have to pass it all in when I build the page.   Analogy
> > would be an , but I don't want an image just
> > some text-based table data.   Or, a SharePoint WebPart that fits in a
> > table, but does its own thing.
>
> > {% block body %}
> > I am well within my body block...
>
> > 
> >   
> >      {{MyModel.A}}, {{MyModel.B}}   
> >        May Exist, May Not... Would like to pull data from another
> > request/response 
> >        May Exist, May Not... Would like to pull data from another
> > request/response  
> > 
> > {% end block %}
>
> > 1.  If this is possible, how do I do it?   Simple example please.
>
> > 2.  If this is poor coding, how is what I'm trying to do best
> > accomplished?
>
> You could do this via AJAX - ie writing some Javascript to request the
> content and inject it into the page - if you really wanted. But I
> can't understand why on earth you'd want to. If you want to show a
> list of model instances, get a queryset in the view and iterate
> through it in the template. Making several request/responses to render
> a simple page will massively increase the load on your server and the
> time it takes for the user to see the finished page.
>
> Can you explain in a bit more detail what you're trying to do, and why
> it couldn't be achieved by simply passing a queryset into the template
> and using the {% for %} tag?
> --
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Easy way to create pretty pages with nav?

2009-04-06 Thread Briel

I mostly agree with andy, getting a base template done as a static
page
would be a great place to start, and how you get it done is up to you
and how you work best.

Step 2 imo would be to add block tags the correct places. Basically
you
want to place your tags in such a way that you only need to repeat the
as less html as possible if you want to change things, but if you
don't want
to change things, they should still work. If your site is simple
enough adding
a variable like {{ context }} might be enough, but building a
structure with
blocks would be a good solution long term.
So if you wanted to have a sub-nav-bar in some pages, you could
implement
the html/css needed in the base template so all that was needed was
some
links, and then just put some block tags within the html that some
template
could fill with the relevant info.

~Jakob

On 6 Apr., 10:35, andybak  wrote:
> Nothing wrong with designing your site using visual tools. Get your
> basic page look and feel set up as a single static HTML + CSS. That
> page becomes your base template.
>
> Stick a single {{ content }} placeholder in and you can start
> inserting dynamic content into your template from any of your views.
>
> Your navigation might become:
>
> 
>   {% for page in pages%}
>     {{page.name}}
>   {% endfor %}
> 
>
> As other parts of your page become dynamic then replace them in the
> same way.
>
> And on the subject of blogs - assuming you start with a working Django
> install and the HTML+CSS already designed then I think anyone
> reasobably familiar with Django could get a working blog in around
> five minutes :)
>
> Andy
>
> On Apr 5, 9:10 pm, dartdog1  wrote:
>
> > So, is a reasonable way to do initial page design to just use some
> > sort of visual tool (suggestions?)(that hopefully does a good job of
> > separating the html and css) then go back in and hack in the Django
> > tags? and blocks?? Or am I just off in left field?
>
> > On Apr 5, 10:43 am, Alex Gaynor  wrote:
>
> > > On Sun, Apr 5, 2009 at 11:38 AM, zayatzz  
> > > wrote:
>
> > > > Im just as new and i ran into exactly the same problem.
>
> > > > As it seems, some people suggest to create new app for just font page
> > > > (or generic public view) and create index.html as this apps front page
> > > > template.
>
> > > > I think it is possible to create views.py and index.html for the
> > > > project too.
>
> > > > Im sure someone will clear all this for us soon enough :).
>
> > > > For now i went for creating app for site. This app will hold stuff
> > > > like website title, meta words, language parameters and website
> > > > encoding - you'll declare them in your index html anyway, so why not
> > > > store them in your database, so you can change them from admin,
> > > > whenever  you want.
>
> > > > Alan
>
> > > > On Apr 5, 5:57 pm, dartdog1  wrote:
> > > > > Ok I'm super new, skimmed the doc & tutorial but I just can't figure
> > > > > out how to go about really building the Public view side? I don't see
> > > > > how to apply simple css. how to set up simple stuff like navigation
> > > > > tabs and links...
>
> > > > > I'm implementing on GAE with the AEP and have gotten the sample app up
> > > > > and going, have more docs to read there. But it seems to me that I'm
> > > > > missing something basic, and when I search for stuff like css and page
> > > > > layout I don't get much help..
>
> > > > > For instance the sample AEP poll app has no style, I was trying to
> > > > > figure out how to apply some,, but at a larger level how to do that
> > > > > for a site, with navigation, and being able to take advantage of the
> > > > > ability to add new apps later?
>
> > > > > I notice that I see a number of people raving about how much they love
> > > > > Django on their WP or Blogger blogs,, Which tells me that even
> > > > > designing a simple Bog is not that easy in Django. Yes I have seen a
> > > > > few Django blogs, but not much discussion of how they did it, and how
> > > > > they apply design. For some they seem to use a mix of other tools and
> > > > > some undisclosed black magic?
>
> > > > > AEP has two sample blogs but truthfully they look pretty primitive.
>
> > > > > What am I missing?
>
> > > Yes, you can absolutely create a views.py that isn't in a application, 
> > > views
> > > are just python functions, so they can live wherever they want, likewise 
> > > so
> > > long as your index.html is in your TEMPLATE_DIRS folder then it can be 
> > > used
> > > from wherever you like.
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right 
> > > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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+unsubscr...@go

Re: Default items in a template

2009-04-06 Thread Briel

If the links are static, you could just hardcode them into the base
template.
That would probably be a bit faster to do, but not as flexible as a
tag would be.

~Jakob

On Apr 6, 7:38 pm, Alex Gaynor  wrote:
> On Mon, Apr 6, 2009 at 11:54 AM, koranthala  wrote:
>
> > Hi,
> >    I have many pages in my website - and all have the same default
> > header and side bars. The header and sidebar contains ~15 links which
> > are constant every time. While rendering templates for these pages, I
> > always have to send all these links in the context. Since it is
> > unseemly, I am planning to write my own context_processor for these
> > headers. Now, I dont want the other template_context_processors to be
> > hit for this - it seems a waste of time. Is it possible to go without
> > hitting the other context_processors - since I would not have hit it
> > otherwise.
>
> It's probably easier for you to just write a custom inclusion tag that
> renders the nav.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Details

2009-04-08 Thread Briel

Hi.

When you have a problem it's great to be explicit about it so we don't
have to both guess your problem and find a solution. Does your 2nd
urlconf throw an error, are the urls not as expected or something
else.
Post tracebacks aswell if errors are thrown, makes it a lot easier to
detect the error and come up with a solution.

~Jakob

On Apr 8, 10:42 pm, zayatzz  wrote:
> >         if 'language' in request.session:
> >                 WTF = 1
> >         else:
> >                 request.session['language'] = 
> > lang.objects.get(fdef=True).short
>
> Figured this one out by trial and error.. replaced in with not in and
> it worked just fine.
>
> Could still use help with url conf
>
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does anyone know how to prepopulate a form with model data

2009-04-08 Thread Briel

Hi.
It seems like your error and your problem is not the same. The error
is complaining about the get_object_or_404, not the profile thing. So
changing that code won't actually do anything as it doesn't get that
far.

~Jakob

On Apr 9, 3:55 am, codecowboy  wrote:
> I want to create a form that allows a user to edit his/her profile.  I
> don't want to bind my form to a model because the form will involve
> two different models.  Does anyone have any ideas.  I've read chapter
> 7 in the Django Book but it only to a simple example that does not
> help me.
>
> Here is what I have tried.
>
> s = get_object_or_404(Scientist, pk=7)
> form = ScientistProfileForm(initial=s)
>
> I've also tried.
>
> form = ScientistProfileForm(s)
>
> I always get the following error message.
>
> Caught an exception while rendering: 'Scientist' object has no
> attribute 'get'
>
> Thanks in advance for any help.  If I figure this out then I will post
> my solution in here in great detail for anyone else that needs 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Authenticate problem

2016-06-17 Thread Briel
Hi
I'm trying to use authenticate like the documentation 
 shown at 
djangoproject, and when I try this authenticate returns None, although the 
user is registered, and the password is right:


from django.contrib.auth import authenticate

...


user = authenticate(username='john', password='secret') #None

usu = User.objects.get(username='john') # usu.password == 'secret'

is there something wrong?
Thank you a lot

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5296d661-e84c-4dda-bfbf-ba93c845aa9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.