Options for migrating from django.contrib.markup for rST

2012-11-24 Thread Darren Spruell
Greetings,

Currently using django.contrib.markup for the restructuredtext filter.
1.5 deprecates the module, and I'd like to start work on replacing it.
What libraries are contenders in this space? Aware of this:

http://code.google.com/p/django-rstify/
https://github.com/bartTC/django-markup
http://packages.python.org/django-markup/

...although this project seems a bit dated.

-- 
Darren Spruell
phatbuck...@gmail.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: django 1.6.0: admin pages not using unicode methods declared in my model

2012-11-24 Thread Lachlan Musicman
I don't think you want unicode, I think you want:

class Meta:
   verbose_name="Company"
   verbose_name_plural = "Companies"

On Sun, Nov 25, 2012 at 8:27 AM, ajendrex  wrote:
> Hello,
>
> I following the tutorial and realized that the admin pages are not using the
> __unicode__() methods declared in my model:
>
> One of my classes:
>
> class Company(models.Model):
>   name = models.CharField(max_length=20)
>   description = models.CharField(max_length=500)
>   url = models.URLField(max_length=200)
>   createdAt = models.DateTimeField(auto_now_add=True)
>
>   def __unicode__(self):
> return self.name
>
> But the admin page to view and add companies shows the current list of
> companies with the label "Company object" instead of the names that I gave
> to those registers. The same happens with the other classes of my model.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/-P162L-ktJYJ.
> 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.



-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

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



set_expiry() auto logout on browser close

2012-11-24 Thread Bill Beal
Hi All,

I'm trying to log the user out automatically when the browser closes.  I
call 'request.session.set_expiry(0)' on login and I'm using
'SESSION_EXPIRE_AT_BROWSER_CLOSE = True' in my settings.  It's not
happening.  The 'How to use sessions' doc (1.4) says this call makes the
session cookie expire when the user's web browser is closed.  When I
abandon my logged-in session and come back the next day without logging in,
I'm still logged in!  What's the mechanism here?  Doesn't 'session expired'
mean logged out?  Do I need to install middleware such as
django-session-security?

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



how to auto-populate(auto-update) model's field(s) via custom button or on Save

2012-11-24 Thread Andriyko
Hello,

Please give an advice and some examples on how can I do the following.
1. I need to fetch some data (list of items) from external url and save 
that list into the field of the, say Model1(possible?)
The problem is not how to fetch, but how to save.
2. This should be done dynamically from admin add/change Model1 page using 
custom button or on Save.
3. Currently I use another Model2 to store that list(ManyToMany). Is it 
possible to store that list as field(and show these items on the Model's 
page) without Model2 so that I can use items of that list in a template?

In short, I want to be able to auto-fill some field of the model on Save 
or/and with custom button. Possible?

Thanks 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZINp_t_15zAJ.
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: count resulting rows in sliced valuesqueryset

2012-11-24 Thread ?manu*
On Saturday, November 24, 2012 8:03:06 AM UTC+1, Peter of the Norse wrote:

> On Nov 21, 2012, at 3:53 AM, ?manu* wrote: 
>
> > Suppose I have a queryset qs. For paginating purposes I need to do 
> something like: 
> > 
> > count = qs.count() 
> > qs = qs[0:100] 
> > 
> > Unfortunately this executes the query twice, which I don't want. 
>
> Are you sure? This is such a common pattern that I suspect that it’s not 
> slower than making it into one query. I ran some tests on the slowest query 
> I have, and the two statements were faster than trying to combine them. 0.2 
> + 1.5 sec vs. 1.9 sec. 
>

You are right! (thanks also to Javier). It is not clear to me how it is 
possible but effectively it seems that the two queries are not slower than 
a single one...

Thank you also for the other answers.

E.
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/zylmsQNJeDoJ.
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: Seeding Foreign Key with known object with Class Based Views

2012-11-24 Thread Lee Hinde

On Nov 24, 2012, at 2:41 PM, Sergiy Khohlov  wrote:

> I would like to clarify:
> 
> 1) you dont need to add client id to the form
> (this value is already  set in your view)
> 
> 2) If you dont know how to  save address let ask
> Of course please add your code. I can not hack your PC and understand
> your problem.
> 
> thanks, Serge
> 2012/11/24 Lee Hinde :
>> nt to seed the client id programmatically without presenting a form
>>> field to enter what's a known value
> 
> -- 


Thanks for sticking with this.

class AddressForm(ModelForm):
def __init__(self, *args, **kwargs):
super(AddressForm, self).__init__(*args, **kwargs)

self.fields['city'].widget.attrs["class"] = 'capme'
self.fields['zip'].widget.attrs["class"] = 'zipcode'
self.fields['state'].widget.attrs["class"] = 'input-mini upper_case'

class Meta:
model = Address
fields = 
('street_one','street_two','city','state','zip','response_type')
exclude = ('client',)


class AddressNew(CreateView):
model = Address
template_name = 'letters/address.html'
form_class = AddressForm
context_object_name = 'myfields'

def get(self, request, *args, **kwargs):
set_current_page(request, "", "active", "", "")
return super(AddressNew, self).get(request, *args, **kwargs)

def get_context_data(self, **kwargs):
context = super(AddressNew, self).get_context_data(**kwargs)
context['client_data'] = get_object_or_404(Client,pk=self.kwargs["pk"])
return context


Then, in the template I'm putting client_data.id into a hidden field to be 
returned when the form is saved.


-- 
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: Tutorial Part 3: loading index.html in browser

2012-11-24 Thread Sergiy Khohlov
 Near too.

 simple example of your fitst template:
http://www.djangobook.com/en/2.0/chapter04.html

 remove all   after  to  and place your code inside this

2012/11/25 Luisa Beck :
> I'm in the process of going through the Django tutorials.
> I'm having trouble with loading the index.html file into the browser. I
> don't see a bulleted-list containing the "What's up" poll from Tutorial 1.
> Instead, I'm simply seeing the code that I pasted from green box (see middle
> of the page in the tutorial- I've also pasted it below).
> The tutorial says "put the following code in that template". Does it mean
> that the code is supposed to go into the index.html file that I created?
>
> Thanks!
>
> {% if latest_poll_list %}
> 
> {% for poll in latest_poll_list %}
> {{ poll.question }}
> {% endfor %}
> 
> {% else %}
> No polls are available.
> {% endif %}
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/xwta_28JByIJ.
> 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.

-- 
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: Tutorial Part 3: loading index.html in browser

2012-11-24 Thread Xavier Ordoquy
Hi Luisa,

Le 24 nov. 2012 à 23:38, Luisa Beck  a écrit :

> I'm in the process of going through the Django tutorials. 
> I'm having trouble with loading the index.html file into the browser. I don't 
> see a bulleted-list containing the "What's up" poll from Tutorial 1. Instead, 
> I'm simply seeing the code that I pasted from green box (see middle of the 
> page in the tutorial- I've also pasted it below). 
> The tutorial says "put the following code in that template". Does it mean 
> that the code is supposed to go into the index.html file that I created?

You are probably looking at the file itself instead of the page rendered by the 
server.
Is that the result you had while looking at http://localhost:8000/polls/ ?

Regards,
Xavier Ordoquy.

> Thanks!
> 
> {% if latest_poll_list %}
> 
> {% for poll in latest_poll_list %}
> {{ poll.question }}
> {% endfor %}
> 
> {% else %}
> No polls are available.
> {% endif %}
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/xwta_28JByIJ.
> 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.

-- 
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: Seeding Foreign Key with known object with Class Based Views

2012-11-24 Thread Sergiy Khohlov
I would like to clarify:

1) you dont need to add client id to the form
(this value is already  set in your view)

2) If you dont know how to  save address let ask
 Of course please add your code. I can not hack your PC and understand
your problem.

 thanks, Serge
2012/11/24 Lee Hinde :
> nt to seed the client id programmatically without presenting a form
>> field to enter what's a known value

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



Tutorial Part 3: loading index.html in browser

2012-11-24 Thread Luisa Beck
I'm in the process of going through the Django tutorials. 
I'm having trouble with loading the index.html file into the browser. I 
don't see a bulleted-list containing the "What's up" poll from Tutorial 1. 
Instead, I'm simply seeing the code that I pasted from green box (see 
middle of the page in the tutorial- I've also pasted it below). 
The tutorial says "put the following code in that template". Does it mean 
that the code is supposed to go into the index.html file that I created?

Thanks!

{% if latest_poll_list %}

{% for poll in latest_poll_list %}
{{ poll.question }}
{% endfor %}
{% else %}
No polls are available.{% endif %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/xwta_28JByIJ.
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: Seeding Foreign Key with known object with Class Based Views

2012-11-24 Thread Lee Hinde
Thanks, but that bit of docs shows that there can be a relationship between
models, but doesn't answer the question I was trying to ask which is, how
to create the relationship in data.


On Thu, Nov 22, 2012 at 12:31 AM, Sergiy Khohlov  wrote:

>
> https://docs.djangoproject.com/en/dev/topics/class-based-views/generic-display/
>  switch  Publisher to client  and  books to address
>  :-)
>
> 2012/11/22 Lee Hinde :
> > I have two tables, Client and Address. Address has a foreign key 'client'
> > which points to the client table. I'll make my user enter a client and
> then
> > enter 1-x Addresses. I'll know which client the address is being linked
> to
> > before the record is created, with a url like : /client/3/address/new/.
> >
> > I want to seed the client id programmatically without presenting a form
> > field to enter what's a known value.
> >
> > I've got this working with method based views, (just throw the client id
> in
> > a hidden field. easy peasy) but can't find an example for what seems to
> me
> > to be a real common need using class based views.
> >
> > The closest I've found are examples relating a user to an object, but
> this
> > isn't quite that and I've spent a fair amount of time trying to adapt the
> > example and either the form complains because the client field is
> missing or
> > there's some other problem.
> >
> > Sooo, I'm hoping that there's an existing example/blog post/stackoverflow
> > question that I've missed that someone could point me to that
> demonstrates
> > this process.
> >
> > Thanks and happy thanksgiving for us US residents. I'll be thankful for
> the
> > non-US folk who might be working and would care to take a shot at this.
> >
> > --
> > 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.
>
> --
> 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.
>
>

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



django 1.6.0: admin pages not using unicode methods declared in my model

2012-11-24 Thread ajendrex
Hello,

I following the tutorial and realized that the admin pages are not using 
the __unicode__() methods declared in my model:

One of my classes:

class Company(models.Model):
  name = models.CharField(max_length=20)
  description = models.CharField(max_length=500)
  url = models.URLField(max_length=200)
  createdAt = models.DateTimeField(auto_now_add=True)

  def __unicode__(self):
return self.name

But the admin page to view and add companies shows the current list of 
companies with the label "Company object" instead of the names that I gave 
to those registers. The same happens with the other classes of my model.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-P162L-ktJYJ.
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.