Django scheduling/calendaring

2019-02-19 Thread Manu Febie
Hello Django developer,

I have been assigned for my first real job as a developer. I have been 
asked to develop a *Learning Management System*. One of the components/apps 
this project must have is a way of managing training programs and projects 
and view them on a calendar. This is how my client wants it. However, I 
have never developed a calender before, so I did my research first on 
Django calendars. There are some tutorials online regarding this topic. But 
I also see there are a ton of ready to use Django Packages for this. So 
basically what I would like to know is if anyone has any experience with 
the Django calendar packages and would recommend me one. 

Thank you.

-- 
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/a62b855b-94ef-4eee-b173-e6fc336d3424%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where to start - New to Django and Python

2018-10-22 Thread manu . pascual . luna
I don't know if it's the best book but I'm enjoying 
http://www.obeythetestinggoat.com. I like 
the 
 

 TDD approach for learning a new technology. Also you can read it for free 
online.


El lunes, 22 de octubre de 2018, 14:02:01 (UTC+2), Lokendar Singh escribió:
>
> Hi Community,
>
> I'm new to django and python, however I've experience in development. 
>
> Can someone suggest me the best book/content/tutor to enhance my skills as 
> a lead developer? 
> Currently I'm going through django documentation.
>
>
> Thanks in advance!
> Lokendar 
>

-- 
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/d3b9f7cb-8379-413b-b626-0eb06f12b2c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using Django Sessions

2018-03-22 Thread Manu Febie
Hello,

I am practicing for my college exams. I am building a Restaurant Order 
System with Django and I am using Django sessions for the first. I borrowed 
some ideas from the "Django by example".

Below you can find the MenuItem model and Order Model.

class MenuItem(models.Model):
   category = models.ForeignKey(Category, related_name='menu_items')
   # table ???
   name = models.CharField(max_length=255, db_index=True)
   slug = models.SlugField(max_length=255, db_index=True, default='')
   description = models.TextField(blank=True)
   image = models.ImageField(upload_to='menu_items/%Y/%m/%d', blank=True)
   price = models.DecimalField(max_digits=10, decimal_places=2)
   available = models.BooleanField(default=True)
   added_on = models.DateTimeField(auto_now_add=True)
   updated = models.DateTimeField(auto_now=True)


class Order(models.Model):
STATUS_CHOICES = (
('in behandeling', 'In behandeling'),
('klaar', 'Klaar')
)
# random_id = models.CharField(max_length=255)
table = models.ForeignKey(settings.AUTH_USER_MODEL)
item = models.ForeignKey(MenuItem, related_name='order_items')
price = models.DecimalField(max_digits=10, decimal_places=2)
quantity = models.PositiveIntegerField(default=1)
status = models.CharField(max_length=50, choices=STATUS_CHOICES, default='in 
behandeling')
paid = models.BooleanField(default=False)
timestamp = models.DateTimeField(auto_now_add=True)


Below you can find a Cart class which handles adding, removing, iterating 
etc. over the Menu Items using Django sessions. What I need is a function 
in this class that only clears the items I have in the cart, but I still 
need the total price. Right now I have the "clear" function which removes 
the entire cart from the session. But since I am kinda confused on how to 
do this I need some help. 

from decimal import Decimal
from django.conf import settings

from menu.models import MenuItem


class Cart:
   
   def __init__(self, request):
   self.session = request.session
   cart = self.session.get(settings.CART_SESSION_ID)
   if not cart:
   cart = self.session[settings.CART_SESSION_ID] = {}
   self.cart = cart

def add(self, menu_item, quantity=1, update_quantity=False):
   # Add a menu item to the cart or update its quantity
   menu_item_id = str(menu_item.id)

if menu_item_id not in self.cart:
   self.cart[menu_item_id] = {'quantity': 0,
  'price': str(menu_item.price)}
   
   if update_quantity:
   self.cart[menu_item_id]['quantity'] = quantity
   else:
   self.cart[menu_item_id]['quantity'] += quantity
   self.save()

def save(self):
   # Update the session cart
   self.session[settings.CART_SESSION_ID] = self.cart
   # Mark the session as "modified" to make sure its saved
   self.session.modified = True

def remove(self, menu_item):
   # Remove a product from the cart
   menu_item_id = str(menu_item.id)
   if menu_item_id in self.cart:
   del self.cart[menu_item_id]
   self.save()

def __iter__(self):
   # Iterate over the item in the cart and get the products from the DB
   menu_item_ids = self.cart.keys()
   # get thte product objects and add them to the cart
   menu_items = MenuItem.objects.filter(id__in=menu_item_ids)
   
   for menu_item in menu_items:
   self.cart[str(menu_item.id)]['menu_item'] = menu_item

for item in self.cart.values():
   item['price'] = Decimal(item['price'])
   item['total_price'] = item['price'] * item['quantity']
   yield item

def __len__(self):
   # Count all the items in the cart
   return sum(item['quantity'] for item in self.cart.values())

def get_total_price(self):
   return sum(Decimal(item['price']) * item['quantity'] for item in self
.cart.values())

def clear(self):
   # Remove cart from the session
   del self.session[settings.CART_SESSION_ID]
   self.session.modified = True

And below here you'll find the view that handles saving the items in the 
request cart in to the Order model. Instead of calling the cart.clear() 
function I need to call a function that removes the ordered items from the 
cart while still having the total price in this session.

@login_required
def create_order(request):
   cart = Cart(request)
   
   if request.method == 'POST':
   for item in cart:
   Order.objects.create(table=request.user,
item=item['menu_item'],
price=item['price'],
quantity=item['quantity'])
   cart.clear()
   return render(request, 'orders/order_success.html', {'cart': cart})
   
   return render(request, 'cart/cart_detail.html', {'cart': cart})

I hope my question is clear and someone can help me with this. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django 

bug in migration squashing

2015-09-08 Thread ?manu*
I had experienced a problem after squashing migrations. The problem is 
described 
here: 
http://stackoverflow.com/questions/31606372/django-migrations-build-graph-has-a-bug

I have not a description of how to reproduce the bug, but I think I can say 
why the source code is wrong (see the link). Do you think this is enough to 
open a bug report?

E.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6c0306f0-10d0-4074-9724-dc1b03d53960%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


GET parameters in admin "add" model page

2014-05-11 Thread ?manu*
I noticed that django admin "add" page reads GET parameters and uses them 
as initial values in the form. However I was not able to pass DateTime 
values in this way. In particular if I try to pass a DateTime value I get a 
"server error". 

See 
http://stackoverflow.com/questions/23559771/django-admin-add-page-initial-datetime-from-get-parameters
 
for more details. 

1. is it possible to pass DateTime values this way?

2. isn't it a bug if a user is able to generate a server error by messing 
with GET parameters?

thanks
E.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4021a36d-81d2-41ff-a160-f04fe0fc8513%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Showing which users are viewing a given page

2014-03-04 Thread Manu
Hey Some Developer,

If you have the option, try http://www.google.com/analytics/.
There are other similar services to get the analytics about real time usage 
statistics about your website.
If you want to identify each individual user, http://kissmetrics.com/ or 
https://mixpanel.com/ are also good bets.
Actually you can do this even in google analytics with a bit of 
customization. Hope it helps.

Regards,
Some other developer

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01646285-d61e-4d84-8a47-d6177f5f8aae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: import

2014-02-11 Thread Manu
Hi Johan,

I don't know if you put sometime into learning python. These imports are a 
way to reuse other modules that already provide some of the functionality 
that you are trying to achieve. To know the right module to import from and 
to select the right things to import, you should consult that package's 
documentation. Like django documentation <http://docs.djangoproject.com/en/>for 
imports from django.

All the best!
- Manu,

On Tuesday, 11 February 2014 15:56:19 UTC+5:30, joh.hendriks wrote:
>
> Hello all. 
>
> I have a little question, maybe a little stupid but non the less it 
> keeps me busy. :-) 
>
> I want to start making some web based apps as a hobby project. 
> I have no coding experience other then some basic shell scripting to get 
> some daily routine jobs done on my FreeBSD servers. 
> The first struggle I had to take is the programming language, I looked 
> at PHP and python, and I think my best option is Python, and with python 
> comes Django. 
> So the last weeks i have been doing some searches on google and view a 
> lot of tutorial video's how to start with django. 
>
> One thing that always comes back is the import part like below 
>
> from  django.http  import  HttpResponse 
>
> And here comes my question, where and how do you know what you need to 
> import. 
> What is the best way to learn al these imports? , and is there a quick 
> way to find the imports you need? 
>
> Thank you for your time. 
>
> regards 
> Johan 
>
>
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1bb02bb9-d284-4fbd-8a9f-0dad4a2bdd4e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Writing your first Django app, part 2 - Customize the admin look and feel

2014-01-15 Thread Manu
Can you post your directory structure here? The problem should be there, 
most probably.

On Wednesday, 15 January 2014 11:37:51 UTC+5:30, Tim DiSabatino wrote:
>
> Hello,
>
> I am just going through the Django Tutorial and am in Writing your first 
> Django app, part 2.  In the section called "Customize the admin look and 
> feel", I have created a templates directory, an admin directory inside of 
> that, and copied the base_site.html file into the admin directory.  I have 
> also added the line below to the settings.py file as instructed:
>
> TEMPLATE_DIRS = [os.path.join(BASE_DIR,'templates')]
>
> However, when I change the  in the base_site.html file, nothing 
> happens.  I have tried moving the templates directory around several times 
> and still no change the admin  text.  It appears that others have had 
> problems with this part of the tutorial in the past for previous versions 
> of Django but the solutions I have tried don't seem to work with Django v 
> 1.6.1.  This part of the tutorial has changed even since Django 1.5.  Can 
> anyone help and tell me what I'm doing incorrectly?  Is is some kind of 
> absolute/relative path issue?  Thanks so much for your help.
>
> -Tim
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dbf18941-866c-4f0e-ab0f-33f32fdd1875%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: nginx server not reflecting changes

2014-01-15 Thread Manu
Please find some of my remarks below

On Tuesday, 14 January 2014 19:04:19 UTC+5:30, sandy wrote:
>
>
> On Sun, Jan 12, 2014 at 9:48 PM, Manu <manu...@gmail.com > 
> wrote:
> >
> > Try to reload nginx. 
> >
> >> sudo nginx -s reload
> >
> >
> > or stop it and restart
> >
> >> sudo nginx -s stop
> >> sudo nginx
> >
> These doesn't make any change.
>
> >
> > if it's still not reflecting those changes, check which settings.py is 
> being used by runserver and the gunicorn. Or, the problem could be that you 
> have to restart gunicorn
> >
> >> sudo supervisorctl restart [gunicorn-program-name]
> >
>
>
How are you so sure that the server is running? Can you try

> $ ps -aux | grep gunicorn

What is it returning to you? 
 

> When I use $ps -aux command to see which gunicorn program is running. It 
> shows no job running, but server is nicely configured and is running. I am 
> new to nginx and gunicorn deployment. Though deployment has been done but 
> am not able to understand why the changes are not visible and which program 
> is running which is behind the deployment.
> Your help will be highly appreciated.
> Thank you.
>
>
> -- 
> Sandeep Kaur
> E-Mail: mkaur...@gmail.com 
> Blog: sandymadaan.wordpress.com
>
>
>
>  

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1b038ad1-f0f4-44bb-ac42-e4482646d679%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: nginx server not reflecting changes

2014-01-12 Thread Manu
Try to reload nginx. 

sudo nginx -s reload


or stop it and restart

sudo nginx -s stop
> sudo nginx


if it's still not reflecting those changes, check which settings.py is 
being used by runserver and the gunicorn. Or, the problem could be that you 
have to restart gunicorn

sudo supervisorctl restart [gunicorn-program-name]


if you changed media root and static root settings then you have to point 
nginx to the right location of those assets in nginx site configuration. 
i.e. in the file that you create inside /etc/nginx/sites-enabled/ for your 
app. Hope you can resolve it.

Best,

On Sunday, 12 January 2014 00:09:19 UTC+5:30, sandy wrote:
>
> Hello,
> I have deployed my Django site with nginx server, gunicorn and supervisor 
> and it is working fine. But recently I made some changes in settings file 
> of the project and that changes are not visible on the nginx server, 
> however same changes reflect on runserver.
> What can be the possible reason for this?
>
> -- 
> Sandeep Kaur
> E-Mail: mkaur...@gmail.com 
> Blog: sandymadaan.wordpress.com
>
>
>
>  

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7103da99-b12e-4f5f-b98a-34e7c1c741d9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Is there any good tutorial on how to daemonize celery?

2013-06-04 Thread Manu
Hi all,

I have had no success so far with daemonizing celery on my server. I raised 
two stack overflow questions and have received only a few answers. Could 
someone please point me to a solid tutorial or blog post on how to make it 
work. I'm using celery with django in a virtual environment.

Btw, the links to those two questions
1. 
http://stackoverflow.com/questions/16896686/daemonizing-celery-process-celeryd-multi-not-found
2. 
http://stackoverflow.com/questions/16915034/is-there-a-simple-manage-py-command-that-i-run-with-django-celery-to-daemonize-c

Thanks in advance for your time! 

Regards,
Manu

-- 
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: internal server error not sending message notification

2013-05-04 Thread ?manu*
Hi Ian,

you suggestion make perfect sense but I'm currently running django 1.4. 
Anyway I tried adding those line to my settings, but nothing has changed...

Any other suggestion? I don't even know how to debug such an issue... 
should I insert breakpoints in the django library?

E.

On Saturday, May 4, 2013 5:06:53 PM UTC+2, Ian Lewis wrote:
>
> Hi,
>
> Did you set your LOGGING configuration in your settings.py? If you 
> happened to upgrade to Django 1.5 then the default LOGGING configuration 
> went away and it will no longer sent emails to the admins without some 
> configuration. This is described at the following url where it says "Prior 
> to Django 1.5": 
> https://docs.djangoproject.com/en/dev/topics/logging/#configuring-logging
>
> You need to set up something like the following for admin error mails to 
> work:
>
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': False,
> 'filters': {
> 'require_debug_false': {
> '()': 'django.utils.log.RequireDebugFalse',
> }
> },
> 'handlers': {
> 'mail_admins': {
> 'level': 'ERROR',
> 'filters': ['require_debug_false'],
> 'class': 'django.utils.log.AdminEmailHandler'
> }
> },
> 'loggers': {
> 'django.request': {
> 'handlers': ['mail_admins'],
> 'level': 'ERROR',
> 'propagate': True,
> },
> }
> }
>
> Hope that helps,
> Ian
>
>
> On Sat, May 4, 2013 at 8:01 AM, ?manu* <emanuele...@gmail.com
> > wrote:
>
>> I suddenly realized that my server is no more sending email notifications 
>> when an internal error occurs. I'm not sure which could be the modification 
>> that caused this behavior. I have the following information:
>>
>> 1. on internal errors the server gives an error not founding template 
>> file 500.html.
>>
>> 2. if I put my 500.html template then django does not complain anymore, 
>> shows the page but does not send the email message.
>>
>> 3. from manage.py shell the command django.core.mail.mail_admins works 
>> fine (email arrives to the admins)
>>
>> Any clue?
>>
>> Thanks,
>> E.
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Ian
>
> http://www.ianlewis.org/ 
>

-- 
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




internal server error not sending message notification

2013-05-04 Thread ?manu*
I suddenly realized that my server is no more sending email notifications 
when an internal error occurs. I'm not sure which could be the modification 
that caused this behavior. I have the following information:

1. on internal errors the server gives an error not founding template file 
500.html.

2. if I put my 500.html template then django does not complain anymore, 
shows the page but does not send the email message.

3. from manage.py shell the command django.core.mail.mail_admins works fine 
(email arrives to the admins)

Any clue?

Thanks,
E.

-- 
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django-allauth: ImproperlyConfigured at /accounts/login/ No Facebook app configured: please add a SocialApp using the Django admin

2012-12-26 Thread Manu
Hi Gabriel, 

Thanks for replying. However, the issue, I think, came up because of the 
incorrect SITE_ID value in my settings.py. 
You can see the conversation at this stackoverflow thread. 
http://stackoverflow.com/questions/14019017/django-allauth-no-facebook-app-configured-please-add-a-socialapp-using-the-djan
 


It's solved for now. :-)
Regards,
Manu

On Tuesday, 25 December 2012 20:16:27 UTC+5:30, Gabriel - Iulian Dumbrava 
wrote:
>
> Hi Manu,
> Enter the admin and at allauth -> apps add a new application of type 
> "Facebook" with your FB credentials. 
>
> You have added a facebook login in settings.py but such a login type is 
> not yet defined in admin. 
>
> I hope this helps!
> Gabriel
>
>

-- 
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/-/NQC82_En1v8J.
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-allauth: ImproperlyConfigured at /accounts/login/ No Facebook app configured: please add a SocialApp using the Django admin

2012-12-24 Thread Manu
Hi, 
I'm facing this error when I access 'accounts/login/'. Posted a question 
here - http://stackoverflow.com/q/14019017/1218897
I would really appreciate any help with it.

Thanks in advance.
-Manu

-- 
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/-/kENl6tSAZDsJ.
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: how to use get_queryset in my code

2012-11-21 Thread ?manu*
On Wednesday, November 21, 2012 7:53:59 AM UTC+1, Nebros wrote:

> Its not a problem of the version, my pycharm gave no error, but it was not 
> possible to generate the model... by generating there was always an 
> error, like it cant find an class or something else
>

Are you sure the problem is on the db API and not in your code?

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



count resulting rows in sliced valuesqueryset

2012-11-21 Thread ?manu*
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. 

I can use postgresql windowing function like that:

qs = q.extra(select = {'count': 'COUNT(*) OVER()'})

to get the 'count' attribute on every object. So far this is very nice. The 
problem is that my queryset qs is actually a ValuesQueryset, i.e. a 
queryset build with .values(...).annotate(...). In this case the extra 
select field is ignored (as reported in the documentation). This makes 
sense because even in postgres it seems not possible to mix window 
functions with "group by" clauses. The solution with raw SQL is the use of 
a subquery. I can get the correct results with the following query, where I 
enclose the sql produced by django in a subquery:

sql = 'SELECT COUNT(*) OVER() , subquery.* FROM (%s) AS subquery' % qs.query

Now the questions:

1. in this snippet qs.query is converted to string. The documentation says 
that parameters in the resulting query string are not correctly escaped, so 
maybe I should take care of SQL injection? How do I get correct escaping of 
parameters?

2. Is it possible to re-attach the sql statement to my ValuesQuerySet? To 
keep the rest of the code unchanged, I need to modify qs so that it 
executes the new raw query. However I don't see how to construct a 
ValuesQueryset with a raw SQL code...

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/-/sqVpNtxw4-YJ.
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: Social networking site

2012-10-12 Thread Manu S Ajith
if you are looking a ready made solution I suggest using ELGG - which is
not Django by the way but a working solution in PHP or Dolphin.

On Fri, Oct 12, 2012 at 2:23 PM, tojo cherian <tojocher...@gmail.com> wrote:

> Hi,
> please help me to model a social networking site which has chats,
> debates, polls, petitions, etc
>
> It would be helpful if anyone can post some link which would help in
> developing a social networking site.
>
> Cheers
> Tojo
>
> --
> 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/-/kpImIxg_ZvsJ.
> 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.
>



-- 

Manu S Ajith
Program Lead,
Ruby Kitchen Technosol Pvt. Ltd.,
Cochin - 682309.
http://rubykitchen.in | m...@rubykitchen.org
(O) 0484 2114850  | (M) +91 9447-786-299

-
I don't like the idea that I'm not in control of my life.
[The Matrix]

-- 
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: consistent (un)capitalization in form labels

2012-05-14 Thread ?manu*
I know I can use the label argument in every field. However this is
very annoying... also this is very complicated for ModelForms where
labels come from Model attributes, and the verbose_name of these
attributes is not useful since it gets capitalized.

On 13 Mag, 20:44, Ejah <ej.huijb...@gmail.com> wrote:
> And, you can specify for each field in a form your own label tekst,
> which will overwrite the default.
> See form fields, label.
> Hth
>
> On 13 mei, 20:42, Ejah <ej.huijb...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I would solve this with css.
> > label {
> >     text-transform: lowercase;}
>
> > Done.
> > Hth.
>
> > On 13 mei, 12:02, "?manu*" <emanuele.paol...@gmail.com> wrote:
>
> > > Hi all,
>
> > > my graphic design prescribes that every label in html FORMS should be
> > > not capitalized and without any suffix. For example, a "my_date" field
> > > should be rendered as:
>
> > > my date > > id="id_date" type="text" class="date" value="10.05.2012" name="date" /
>
> > > >
>
> > > To achieve this I need to set a "label" attribute in every Form. For
> > > ModelForm (Forms automatically created from models) my only
> > > possibility is to rewrite the entire form "by hand" in the HTML
> > > template file.
>
> > > Is there a better way to achieve this beahviour? Is it possible to
> > > redefine the function used to convert the field name to the field
> > > label?
>
> > > E.

-- 
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: consistent (un)capitalization in form labels

2012-05-14 Thread ?manu*
Nice. I think this will be my solution!

On 13 Mag, 20:42, Ejah <ej.huijb...@gmail.com> wrote:
> I would solve this with css.
> label {
>     text-transform: lowercase;}
>
> Done.
> Hth.
>
> On 13 mei, 12:02, "?manu*" <emanuele.paol...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > my graphic design prescribes that every label in html FORMS should be
> > not capitalized and without any suffix. For example, a "my_date" field
> > should be rendered as:
>
> > my date > id="id_date" type="text" class="date" value="10.05.2012" name="date" /
>
> > >
>
> > To achieve this I need to set a "label" attribute in every Form. For
> > ModelForm (Forms automatically created from models) my only
> > possibility is to rewrite the entire form "by hand" in the HTML
> > template file.
>
> > Is there a better way to achieve this beahviour? Is it possible to
> > redefine the function used to convert the field name to the field
> > label?
>
> > E.

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



consistent (un)capitalization in form labels

2012-05-13 Thread ?manu*
Hi all,

my graphic design prescribes that every label in html FORMS should be
not capitalized and without any suffix. For example, a "my_date" field
should be rendered as:

my date

To achieve this I need to set a "label" attribute in every Form. For
ModelForm (Forms automatically created from models) my only
possibility is to rewrite the entire form "by hand" in the HTML
template file.

Is there a better way to achieve this beahviour? Is it possible to
redefine the function used to convert the field name to the field
label?

E.

-- 
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 change column name in many2many relations?

2012-01-12 Thread ?manu*
I have solved by defining the model of the relation with a "through"
attribute. A little lenghty but effective...

E.

On Jan 12, 11:01 am, "?manu*" <emanuele.paol...@gmail.com> wrote:
> Is it possible to change the column name in many2many relations?
>
> I can change in in foreignKeys with the db_column attribute. I can
> change the table name in many2many relations with db_table. What about
> column names in many2many relations?
>
> Thanks,
> E.

-- 
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 change column name in many2many relations?

2012-01-12 Thread ?manu*
Is it possible to change the column name in many2many relations?

I can change in in foreignKeys with the db_column attribute. I can
change the table name in many2many relations with db_table. What about
column names in many2many relations?

Thanks,
E.

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



ValidationError to error message

2011-12-04 Thread ?manu*
I cannot understand the following behaviour:

>>> from django.core.exceptions import ValidationError
>>> str(ValidationError('so and so'))
"[u'so and so']"
>>> str(Exception('so and so'))
'so and so'

How do I convert a ValidationError to a str for composing a human
readable message? Even if ValidationError is derived from Exception,
its conversion to str is different... what is the right way to get the
message in a ValidationError?

E.

-- 
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: all data of all manyToMany relations lost!

2011-05-13 Thread ?manu*
Maybe I found the offending command!! Here is what I wrote:


# T is some model in my model.py
opts = T._meta
fields = opts.fields
fields.extend(opts.many_to_many)
...

This is awful! I'm erroneously modifying the fields value of my
model!

E.

On 13 Mag, 23:45, "?manu*" <emanuele.paol...@gmail.com> wrote:
> Dear experts,
>
> today I was inspecting the ManyToMany relations in the _meta subclass
> of a Model class of my database. At some time I realized that all data
> associated to such relations was lost in the database! The
> corresponding tables are empty. Other fields and relations are ok.
>
> I suspect I have issued some command (working from the shell issued
> with manage.py) which erased the field form the data model and
> consequently all the corresponding data has been deleted. Can you
> imagine what kind of action may have I done?
>
> I suspect there is no way to recover the lost data, apart from backup
> isn't it? (the database engine is mysql).
>
> Today I'm very sad...
>
> Thank you in advance for any suggestion.
>
> E.

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



all data of all manyToMany relations lost!

2011-05-13 Thread ?manu*
Dear experts,

today I was inspecting the ManyToMany relations in the _meta subclass
of a Model class of my database. At some time I realized that all data
associated to such relations was lost in the database! The
corresponding tables are empty. Other fields and relations are ok.

I suspect I have issued some command (working from the shell issued
with manage.py) which erased the field form the data model and
consequently all the corresponding data has been deleted. Can you
imagine what kind of action may have I done?

I suspect there is no way to recover the lost data, apart from backup
isn't it? (the database engine is mysql).

Today I'm very sad...

Thank you in advance for any suggestion.

E.

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



Auth tests fail, remote_user

2010-04-27 Thread manu CAZ
Hi,

Tests of the  auth app are failing with my environnement, especially the
remote_user tests.
I didn't try to custom this app or anything. 'admin' , 'sites'  and
'contenttypes' are in my INSTALLED_APPS.

Did I missed a dependency ?

Here is a traceback:

ERROR: test_known_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 160, in test_known_user
super(RemoteUserCustomTest, self).test_known_user()
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
  File "/usr/lib/python2.5/site-packages/django/template/context.py", line
44, in __getitem__
raise KeyError(key)
KeyError: 'user'

==
ERROR: test_last_login
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 87, in test_last_login
self.assertNotEqual(default_login, response.context['user'].last_login)
  File "/usr/lib/python2.5/site-packages/django/template/context.py", line
44, in __getitem__
raise KeyError(key)
KeyError: 'user'

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 33, in test_no_remote_user
self.assert_(isinstance(response.context['user'], AnonymousUser))
  File "/usr/lib/python2.5/site-packages/django/template/context.py", line
44, in __getitem__
raise KeyError(key)
KeyError: 'user'

==
ERROR: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserCustomTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 168, in test_unknown_user
super(RemoteUserCustomTest, self).test_unknown_user()
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 51, in test_unknown_user
self.assertEqual(response.context['user'].username, 'newuser')
  File "/usr/lib/python2.5/site-packages/django/template/context.py", line
44, in __getitem__
raise KeyError(key)
KeyError: 'user'

==
ERROR: test_known_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 67, in test_known_user
self.assertEqual(response.context['user'].username, 'knownuser')
  File "/usr/lib/python2.5/site-packages/django/template/context.py", line
44, in __getitem__
raise KeyError(key)
KeyError: 'user'

==
ERROR: test_last_login
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 87, in test_last_login
self.assertNotEqual(default_login, response.context['user'].last_login)
  File "/usr/lib/python2.5/site-packages/django/template/context.py", line
44, in __getitem__
raise KeyError(key)
KeyError: 'user'

==
ERROR: test_no_remote_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 33, in test_no_remote_user
self.assert_(isinstance(response.context['user'], AnonymousUser))
  File "/usr/lib/python2.5/site-packages/django/template/context.py", line
44, in __getitem__
raise KeyError(key)
KeyError: 'user'

==
ERROR: test_unknown_user
(django.contrib.auth.tests.remote_user.RemoteUserNoCreateTest)
--
Traceback (most recent call last):
  File
"/usr/lib/python2.5/site-packages/django/contrib/auth/tests/remote_user.py",
line 118, in test_unknown_user

another tutorial for polls...

2009-12-14 Thread Manu
Hi all,

Following the announce of some tools of mine (obviews)... I've just
add a practical example, inspired from django tutorial on polls.

The theory is on a standalone page describing the views used in this
simple poll application (http://www.obviews.com/polls/)... Anyhow,
somones need a few less theory and a bit more show... so you will find
the real polls on http://polls.obviews.com, with (as you guessed) real
stuff like polls and choices and votes (and code too).

Keep in mind the demo is very simple, its purpose being more a demo...
than a poll app :)
Any feedback welcome !

Manu

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Initial values and unbound forms (apparently a bug?)

2009-12-06 Thread Manu
Hello,

I would say that the behavior you have is normal. Quoting the doc

"Using initial data with a formset:
Initial data is what drives the main usability of a formset. As shown
above you can define the number of extra forms. What this means is
that you are telling the formset how many additional forms to show
**in addition** to the number of forms it generates from the initial
data."


What I understood from the doc is that initial values are used for
existing objects or ones being built. Ie, if you provided 6 forms with
default values in a formset, you will end up with 6 new objects
created/modified. It's up to you then to really create/modfiy those
objects.

Consequently a solution for you would be to set extra=0 and set up you
inital datas as you have done but not create objects if default
values have not been changed (for instance).

Manu

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Where to store repetitive form logic?

2009-12-06 Thread Manu
I got the same need and wrote up a FormView wich handles all the
repetitive process of a form.

In your case, you could build your view like this: http://dpaste.com/129827/
You will find basic example (and explanations) here:
http://www.obviews.com/form/simplest/.

Hope this helps,
Manu

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




[ANN] obviews: object oriented views

2009-12-05 Thread Manu
Hi all,

My first post to share an habit of mine that you might find useful: it
deals with views and wraps them into objects.

I have replaced the functions with objects for a while now, found it
very handy and add pieces of code here and there in my little home-
land, but never shared it. Which might be common, but still not really
grateful. So I am refactoring all bit by bit and making some releases
when I feel its readable. The starting point if you are interested
could be on www.obviews.com, a demo web-site that will replace any
long speech.

Do not hesitate posting some feedback,
Manu

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: djangobook.com sourcecode

2008-12-05 Thread Manu


> If you go and read about the comments system on the site, it tells you
> (see:http://djangobook.com/about/comments/) exactly where it came
> from:
>
> "Many, many thanks to Jack Slocum; the inspiration and much of the
> code for the comment system comes from Jack's blog, and this site
> couldn't have been built without his wonderful YAHOO.ext library.
> Thanks also to Yahoo for YUI itself."
>
> There are even links in that paragraph to help you go find the stuff.

I already did that and more before asking the question.
1. The link to Jack Slocum blog in that page is broken. His new blog/
site no longer has that type of commenting system.
2. Extjs does not provide old versions of their code for download.
Their new version is licensed in a very messy fashion making it
impossible to use in almost any project without buying their
commercial license.
Some info on that can be found at http://pablotron.org/?cid=1556. They
also claimed that extjs licensed under LGPL was not actually LGPL and
should not be distributed. I think the version used on djangobook.com
was based on the BSD/public domain licensed initial extjs which is
free of all this mess.
3. I was interested in the django source code as well to see how the
extjs comments was integrated.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



djangobook.com sourcecode

2008-12-05 Thread Manu

Has the source code for djangobook.com ever released ? Is there a plan
to release it if it is not released ? And lastly does anyone know of
any projects which can provide the comments functionality of
djangobook.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Update database field

2006-11-18 Thread Manu J

Hi,

This is what i ended up doing in a project of mine.But this involved
two DB calls
 One to retrieve and another to save, but with just SQL can be
accomplished in a
single UPDATE statement.
Django docs menthion that if you explicitly specify an  id (primary
key ) it should update the db. So I did something like this

i = Item.(id=4, name='New Name')
i.save()

The Item model has a created_at column, which is sent NULL if I do
this. Hence the query fails.  There shoud be a better way of doing it.

--
Manu

On 11/14/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Yea, that will work.
>
> Get the "thing"
> change the value
> store it.
>
>
> tinti wrote:
> > Got it:
> >
> > update = Queue.objects.get(message=message_id)
> > update.read = 1
> > update.save()
> >
> > I thinks this is the correct way, if not somebody can advise me another
> > ;)
> >
> > On Nov 14, 11:37 am, "tinti" <[EMAIL PROTECTED]> wrote:
> > > Hi all,
> > > I need some help updating a database field. Can someone post me an
> > > example on updating a database field using the views.py and a static
> > > value to update. For example each time an item is requested set the
> > > field read to 1. I have to build something similar.
> > >
> > > Thanks for any reply
> > >
> > > tinti
>
>
> >
>

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Want to see your favorite branch merged? Here's how you can help!

2006-11-16 Thread Manu J

1. Row level permissions
2. Schema Evolution

--
Manu

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to find out the id of the last record in a table?

2006-11-16 Thread Manu J

On 11/16/06, Don Arbow <[EMAIL PROTECTED]> wrote:
>
> On Nov 15, 2006, at 9:58 PM, simonbun wrote:
> >
> > The problem with getting the last record's id and using it, is that
> > someone might have inserted yet another record while you're still
> > working on the previous one.
> >
> > For single user scenario's it's ok, or if you're using table level
> > write locking. Yet afaik, its generally a bad idea.
>
>
>
> Not sure how it works in MySQL, but in Postgres, getting the last
> inserted id is unique to the current user's (database) session. So if
> a user inserts a record into the table, then queries the sequence for
> that id, the value will always be the same, regardless if other table
> insertions have been done by other users since the first insertion.
> So the last inserted id should be thought of as the id inserted by
> this user, not the maximum id inserted by any user.

Yes, this is the functionality that i'm seeking. The id of the object
most recently
saved on a per user(connection) basis. In case of MySQL (5.0) the id
is unique to
connection. Here is the relevant portion frrom the docs

"For LAST_INSERT_ID(), the most recently generated ID is maintained in
the server on a per-connection basis. It is not changed by another
client."

Don't know about pre-5.0 versions, but i guess it is the same.


>
> The easiest way to get the last inserted id is to create an object,
> save it, then read its id directly. If you need the maximum inserted
> id, use select max(id) from table.

To do this you should be using the create method and not the save method
since the save does not return the object saved.

p = Person.objects.create(first_name="Bruce", last_name="Springsteen")
p.id

will give you the id of the object saved.
(example from the docs )


--
Manu

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to find out the id of the last record in a table?

2006-11-15 Thread Manu J

There is a get_last_insert_id() function defined in the backend
models. Can that be used somehow ?

--
Manu

On 11/15/06, Pythoni <[EMAIL PROTECTED]> wrote:
>
> Thank you very much for help
> L.
>
>
> >
>

--~--~-~--~~~---~--~~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---