Re: Data Structure - Orders and multiple items

2013-03-31 Thread Siddharth Ghumre
Sorry for the half response...please ignore the previous message.

class order(models.Model):
order_id = models.IntegerField(unique=True)
customer_id = models.ForeignKey('Customer')
item_id = models.ForeignKey('Item')
qty = models.IntegerField()

This will you give the provision to store multiple items to be added
against each customer and the quantity of the order against each customer.

-Siddharth



On Mon, Apr 1, 2013 at 9:37 AM, Eric Lovrien  wrote:

> I am not sure of how or the best way to structure my data in models.py. I
> would like to have an order and allow multiple items / products to be added
> to an order. I know I can do a ManyToMany field but not sure how I would
> connect a qty to that. I am sure there is some simple way of doing this, or
> a better way to model the data. I know in many ERP systems they have an
> orders table and then an orders details table. Below is just a quick
> mock-up of how i was thinking on to do it until I started thinking about
> the many items and qty to an single order issue came up. Can any one give
> me some tips on how to accomplish this?
>
>
>
> class Item(models.Model):
> name = models.CharField(max_length200)
> description = models.TextField(blank=True)
>
> def __unicode__(self):
>  return self.name
>
> class Customer
> first_name = models.CharField(max_length=100)
> last_name = models.CharField(max_length=100)
> address = models.CharField(max_length=200)
>
> def __unicode__(self):
> return self.name
>
> class order(models.Model):
> order = models.IntegerField(unique=True)
> customer = models.ForeignKey('Customer')
>
> --
> 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.
>
>
>

-- 
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: Data Structure - Orders and multiple items

2013-03-31 Thread Siddharth Ghumre
Hi

As per my view you can modify your models as follows:-

class order(models.Model):
order_id = models.IntegerField(unique=True)
customer_id = models.ForeignKey('Customer')
item_id = models.ForeignKey('Item')




On Mon, Apr 1, 2013 at 10:30 AM, Lachlan Musicman  wrote:

> On 1 April 2013 15:07, Eric Lovrien  wrote:
> > I am not sure of how or the best way to structure my data in models.py. I
> > would like to have an order and allow multiple items / products to be
> added
> > to an order. I know I can do a ManyToMany field but not sure how I would
> > connect a qty to that. I am sure there is some simple way of doing this,
> or
> > a better way to model the data. I know in many ERP systems they have an
> > orders table and then an orders details table. Below is just a quick
> mock-up
> > of how i was thinking on to do it until I started thinking about the many
> > items and qty to an single order issue came up. Can any one give me some
> > tips on how to accomplish this?
>
>
> Use an intermediary model as described in the docs:
>
>
> https://docs.djangoproject.com/en/1.5/topics/db/models/#extra-fields-on-many-to-many-relationships
>
> This will be your best bet I think.
>
> L.
>
>
>
> >
> >
> >
> > class Item(models.Model):
> > name = models.CharField(max_length200)
> > description = models.TextField(blank=True)
> >
> > def __unicode__(self):
> >  return self.name
> >
> > class Customer
> > first_name = models.CharField(max_length=100)
> > last_name = models.CharField(max_length=100)
> > address = models.CharField(max_length=200)
> >
> > def __unicode__(self):
> > return self.name
> >
> > class order(models.Model):
> > order = models.IntegerField(unique=True)
> > customer = models.ForeignKey('Customer')
> >
> > --
> > 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.
> >
> >
>
>
>
> --
> The new creativity is pointing, not making. Likewise, in the future,
> the best writers will be the best information managers.
>
>
> http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith
>
> --
> 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.
>
>
>

-- 
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: Data Structure - Orders and multiple items

2013-03-31 Thread Lachlan Musicman
On 1 April 2013 15:07, Eric Lovrien  wrote:
> I am not sure of how or the best way to structure my data in models.py. I
> would like to have an order and allow multiple items / products to be added
> to an order. I know I can do a ManyToMany field but not sure how I would
> connect a qty to that. I am sure there is some simple way of doing this, or
> a better way to model the data. I know in many ERP systems they have an
> orders table and then an orders details table. Below is just a quick mock-up
> of how i was thinking on to do it until I started thinking about the many
> items and qty to an single order issue came up. Can any one give me some
> tips on how to accomplish this?


Use an intermediary model as described in the docs:

https://docs.djangoproject.com/en/1.5/topics/db/models/#extra-fields-on-many-to-many-relationships

This will be your best bet I think.

L.



>
>
>
> class Item(models.Model):
> name = models.CharField(max_length200)
> description = models.TextField(blank=True)
>
> def __unicode__(self):
>  return self.name
>
> class Customer
> first_name = models.CharField(max_length=100)
> last_name = models.CharField(max_length=100)
> address = models.CharField(max_length=200)
>
> def __unicode__(self):
> return self.name
>
> class order(models.Model):
> order = models.IntegerField(unique=True)
> customer = models.ForeignKey('Customer')
>
> --
> 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.
>
>



--
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

-- 
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: Hey! I'm recieving an index error when trying to import models, and I can't figure out why.

2013-03-31 Thread Jonathan Baker
When importing Python modules, you don't need to include the '.py' file
extension. So,
from models.py import UUID
...needs to be:
from models import UUID

Hope this helps,
Jonathan


On Sun, Mar 31, 2013 at 10:27 PM, C Alaric Moore wrote:

> Hello,
>
> I am incredibly new to Django, as-of-today new, so forgive me if I've
> missed something really obvious.
>
> I've been going through the tutorial and did so mostly-successfully and
> decided to redo it with my own code.
>
> Everything was going fine until I decided that it would be a good idea to
> type from models.py import UUID, Students into the shell. With this I
> received the following error:
>
> /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/db/models/base.pyc
> in __new__(cls, name, bases, attrs)
>  90 # For 'django.contrib.sites.models', this would be
> 'sites'.
>
>  91 model_module = sys.modules[new_class.__module__]
> ---> 92 kwargs = {"app_label":
> model_module.__name__.split('.')[-2]}
>  93 else:
>  94 kwargs = {}
>
> IndexError: list index out of range
>
> I went onto stackoverflow and found some people had similar issues a year
> ago, and suggested that a person delete the pyc files, which I did. It was
> also suggested that you make DEBUGGING = False, or True or whatever is
> opposite. I did this, too, only to find the same error.
>
> I did some other things too, all to no avail... all the same error. I even
> checked to make sure I was saving edited files, TWICE. Still, same error.
>
> With this, I ask for your help o' wise ones.
>
> Thanks.
>
>
>  --
> 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.
>
>
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Hey! I'm recieving an index error when trying to import models, and I can't figure out why.

2013-03-31 Thread C Alaric Moore
Hello, 

I am incredibly new to Django, as-of-today new, so forgive me if I've 
missed something really obvious. 

I've been going through the tutorial and did so mostly-successfully and 
decided to redo it with my own code. 

Everything was going fine until I decided that it would be a good idea to 
type from models.py import UUID, Students into the shell. With this I 
received the following error: 

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/django/db/models/base.pyc
 
in __new__(cls, name, bases, attrs)
 90 # For 'django.contrib.sites.models', this would be 
'sites'.

 91 model_module = sys.modules[new_class.__module__]
---> 92 kwargs = {"app_label": 
model_module.__name__.split('.')[-2]}
 93 else:
 94 kwargs = {}

IndexError: list index out of range

I went onto stackoverflow and found some people had similar issues a year 
ago, and suggested that a person delete the pyc files, which I did. It was 
also suggested that you make DEBUGGING = False, or True or whatever is 
opposite. I did this, too, only to find the same error. 

I did some other things too, all to no avail... all the same error. I even 
checked to make sure I was saving edited files, TWICE. Still, same error. 

With this, I ask for your help o' wise ones. 

Thanks. 


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




Data Structure - Orders and multiple items

2013-03-31 Thread Eric Lovrien
I am not sure of how or the best way to structure my data in models.py. I 
would like to have an order and allow multiple items / products to be added 
to an order. I know I can do a ManyToMany field but not sure how I would 
connect a qty to that. I am sure there is some simple way of doing this, or 
a better way to model the data. I know in many ERP systems they have an 
orders table and then an orders details table. Below is just a quick 
mock-up of how i was thinking on to do it until I started thinking about 
the many items and qty to an single order issue came up. Can any one give 
me some tips on how to accomplish this? 



class Item(models.Model): 
name = models.CharField(max_length200) 
description = models.TextField(blank=True) 

def __unicode__(self): 
 return self.name 

class Customer 
first_name = models.CharField(max_length=100) 
last_name = models.CharField(max_length=100) 
address = models.CharField(max_length=200) 

def __unicode__(self): 
return self.name 

class order(models.Model): 
order = models.IntegerField(unique=True) 
customer = models.ForeignKey('Customer') 

-- 
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: how do I specify optional params in url?

2013-03-31 Thread frocco
Ok, I understand and will try and provide more detail in the future.

Thanks again

On Sunday, March 31, 2013 5:28:54 PM UTC-4, Alexis Roda wrote:
>
> Al 31/03/13 22:43, En/na frocco ha escrit: 
> > Thank you for taking the time to help me. 
>
> You're welcome. 
>
> One last thing. I'm not a native english speaker, so if I sound rude 
> it's not my intention. That said ... 
>
> When you ask for help in the list try to include more information: the 
> error message, explain what you're doing, what input do you provide, 
> what result do you expect and what result do you get, provide some 
> sample code etc. 
>
> Try to be clear and concise .. but not as concise as "this does not work" 
> ;) 
>
> Also, when replying to a message keep some of the relevant context. That 
> will help the reader in knowing what has been done so far. 
>
>
> In short: help us to help you. 
>
>
>
> Regards 
>
>

-- 
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: Using Django docs to find widget readonly specification

2013-03-31 Thread Alexis Roda

Al 31/03/13 23:42, En/na AJP ha escrit:

I'm new to learning Django.  I want to find the documentation regarding
the readonly attribute you can set for admin widgets.


Do you mean?

https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields

It's linked in the front page (https://docs.djangoproject.com/en/1.5/), 
in the "The admin" section, "Admin site".


Also, googling for "django admin readonly field" returns the page in the 
first place.



Regards

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




Using Django docs to find widget readonly specification

2013-03-31 Thread AJP
I'm new to learning Django.  I want to find the documentation regarding the 
readonly attribute you can set for admin widgets.  For example, from an 
admin.py:

class SourceForm(forms.ModelForm):
  data = forms.CharField(widget=TextInput(attrs={'readonly': True, 'class': 
'averageField'}))

  class Meta:
model = Source


class SourceAdmin(admin.ModelAdmin):
  form = SourceForm

admin.site.register(Source, SourceAdmin)


I've search for readonly on 
https://docs.djangoproject.com/search/?q=readonly&release=7 but did not 
found anything.  Also searching manually in 
https://docs.djangoproject.com/en/dev/ref/forms/widgets/ didn't bring 
anything up.  Can someone tell me where I'm going wrong please.

-- 
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: how do I specify optional params in url?

2013-03-31 Thread Alexis Roda

Al 31/03/13 22:43, En/na frocco ha escrit:

Thank you for taking the time to help me.


You're welcome.

One last thing. I'm not a native english speaker, so if I sound rude 
it's not my intention. That said ...


When you ask for help in the list try to include more information: the 
error message, explain what you're doing, what input do you provide, 
what result do you expect and what result do you get, provide some 
sample code etc.


Try to be clear and concise .. but not as concise as "this does not work" ;)

Also, when replying to a message keep some of the relevant context. That 
will help the reader in knowing what has been done so far.



In short: help us to help you.



Regards

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




(1242, 'Subquery returns more than 1 row')

2013-03-31 Thread Satinderpal Singh
I have the following error in my project

(1242, 'Subquery returns more than 1 row')

my views are as given below

def result_cube(request):
Id = Cube.objects.aggregate(Max('Report_id'))
ID = Id['Report_id__max']
cubee = Cube.objects.filter(Report_id = ID)
Id = Report.objects.aggregate(Max('id'))
ID = Id['id__max']
Head = Report.objects.filter(id = ID)
organisation = Organisation.objects.all().filter(id = 1)
department = Department.objects.all().filter(id = 1)

Id = Report.objects.aggregate(Max('job'))
ID = Id['job__max']
job = Report.objects.filter(job = ID)

client =
Job.objects.all().filter(client=job).values('client__client__first_name',
'client__client__middle_name', 'client__client__last_name',
'client__client__address', 'client__client__city', 'date',
'letter_no', 'letter_date')

temp = {'client':client, 'cubee':cubee, 'Head':Head,
'organisation':organisation,'department':department,}
return render_to_response('report/cube.html',
dict(temp.items() + tmp.items()),
context_instance=RequestContext(request))


Error during template rendering

In template /home/satinder/Automation/templates/report/header.html,
error at line 12

2 {% load i18n %}
3 
4 {% block content %}
5 
6 {% for Heads in Head %}
7 
8 No.GNDEC/TCC/R/{{Heads.job_id}}Dated{{Heads.dispatch_report_date}}
9 
10  To,
12 {% for add in client %}
13  {{ add.client__client__first_name}} {{
add.client__client__middle_name}}
{{add.client__client__last_name}}
14  {{add.client__client__address}}
15 {{ add.client__client__city}}
16 {% endfor %}
17

Can anybody help me to solve this error.


--
Satinderpal Singh
http://devplace.in/~satinder/wordpress/
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

-- 
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: I get import errors when I run django-admin.py startproject in Windows

2013-03-31 Thread Brek Cooney
Thanks for your help Karen. 

I enter  
python C:\python33\scripts\django-admin.py startproject mysite

The response I get is 
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\django\core\management\templates.py", 
line  12, in 
from urllib.request import urlretrieve
  File "C:\Python33\lib\urllib\request.py", line 88, in 
import http.client
  File "C:\Python33\Lib\site-packages\django\http\__init__.py", line 1, in 

from django.http.cookie import SimpleCookie, parse_cookie
  File "C:\Python33\lib\site-packages\django\http\__init__.py", line 1, in 

from django.http.cookie import SimpleCookie, parse_cookie
  File "C:\Python33\lib\site-packages\django\http\cookie.py", line 5, in 

from django.utils.six.moves import http_cookies
  File "C:\Python33\lib\site-packages\django\utils\six.py", line 84, in 
__get__
result = self._resolve()
  File "C:\Python33\lib\site-packages\django\utils\six.py", line 103, in 
_resolve
return _import_module(self.mod)
  File "C:\Python33\lib\site-packages\django\utils\six.py", line 74, in 
_import_module
__import__(name)
ImportError: No module named 'http.cookies'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\python33\scripts\django-admin.py", line 5, in 
management.execute_from_command_line()
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", 
line
453, in execute_from_command_line
utility.execute()
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", 
line
392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", 
line
272, in fetch_command
klass = load_command_class(app_name, subcommand)
  File "C:\Python33\lib\site-packages\django\core\management\__init__.py", 
line
77, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python33\lib\site-packages\django\utils\importlib.py", line 35, 
in im
port_module
__import__(name)
  File 
"C:\Python33\lib\site-packages\django\core\management\commands\startproje
ct.py", line 2, in 
from django.core.management.templates import TemplateCommand
  File "C:\Python33\lib\site-packages\django\core\management\templates.py", 
line
 14, in 
from urllib import urlretrieve
ImportError: cannot import name urlretrieve


My path includes my Python directory and Scripts sub-directory. My Python 
path includes Python\DLLs, Python\Scripts and 
Python\Lib\site-packages\django. I hope that this gives you the information 
you need to help me out. If not, please tell me what else I can provide. 
Thanks again for your help.


On Sunday, March 31, 2013 6:33:39 AM UTC-7, Karen Tracey wrote:
>
> What errors, exactly? Without some specifics of what's going wrong it's 
> hard to offer help. Copy/paste of exactly what you are entering and getting 
> in response would help.
>
>
>
>  

-- 
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: how do I specify optional params in url?

2013-03-31 Thread frocco
Thank you for taking the time to help me.

On Sunday, March 31, 2013 1:00:24 PM UTC-4, frocco wrote:
>
> Hello,
>
> Here is my current url.
>
>url(r'^narrow_category/(\d+)/(\w*)/(\d*)/(\d*)/(\d*)/$', 
> 'catalog.views.narrow_category', name="narrow_category"),
>
> d+ is required
> w* can be optional
> last three d* can be optional
>
> This setting is not working.
>
> What am I doing wrong?
>
> Thanks
>

-- 
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: how do I specify optional params in url?

2013-03-31 Thread Alexis Roda

Al 31/03/13 21:55, En/na frocco ha escrit:

I am kinda lost with url encoding being a newbie in django.

I do not see my error.

  Can you give me an example?


Here it is:

views.py:

  def my_view(request, foo, bar="spam"):
  pass

urls.py

  # choose descriptive names for the views
  ...
  url(r"^narrow/(\d+)/$", views.my_view, name="narrow1"),
  url(r"^narrow/(\d+)/(\w+)/$", views.my_view, name="narrow2"),
  ...

in python code (views etc.):

  reverse("narrow1", args=(23, )) -> ".../narrow/23/"
  reverse("narrow2", args=(23, "foo")) -> ".../narrow/23/foo"

in templates:

  {% url "narrow1" 23 %}  -> ".../narrow/23/"
  {% url "narrow2" 23 "foo" %} -> ".../narrow/23/foo/"

Important: if you're using django < 1.5 you should remove the quotes 
around the view name in the url tag.





HTH

--
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: how do I specify optional params in url?

2013-03-31 Thread frocco

>
> I am kinda lost with url encoding being a newbie in django.

I do not see my error.

 Can you give me an example?

Thanks 

-- 
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: how do I specify optional params in url?

2013-03-31 Thread Alexis Roda


El diumenge 31 de març de 2013 21:01:55 UTC+2, frocco va escriure:
>
>  url(r'^narrow_category/(\d+)/$', 'catalog.views.narrow_category', 
> name="narrow_category"),
> url(r'^narrow_category/(\d+)/(\w+)/$', 
> 'catalog.views.narrow_category', name="narrow_category"),
> url(r'^narrow_category/(\d+)/(\w+)/(\d+)/$', 
> 'catalog.views.narrow_category', name="narrow_category"),
> url(r'^narrow_category/(\d+)/(\w+)/(\d+)/(\d+)/$', 
> 'catalog.views.narrow_category', name="narrow_category"),
> url(r'^narrow_category/(\d+)/(\w+)/(\d+)/(\d+)/(\d+)/$', 
> 'catalog.views.narrow_category', name="narrow_category"),
>
> def narrow_category(request, pk, search='', size1='', size2='', size3=''):
>  
> Page not found (404)Request Method:GETRequest URL:
> http://127.0.0.1:8000/narrow_category/8/2657018///
>

I missed this in my first read: you should give each rule a different name.


Regards

-- 
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: how do I specify optional params in url?

2013-03-31 Thread Alexis Roda

Al 31/03/13 21:01, En/na frocco ha escrit:

  url(r'^narrow_category/(\d+)/$', 'catalog.views.narrow_category',
name="narrow_category"),
 url(r'^narrow_category/(\d+)/(\w+)/$',
'catalog.views.narrow_category', name="narrow_category"),
 url(r'^narrow_category/(\d+)/(\w+)/(\d+)/$',
'catalog.views.narrow_category', name="narrow_category"),
 url(r'^narrow_category/(\d+)/(\w+)/(\d+)/(\d+)/$',
'catalog.views.narrow_category', name="narrow_category"),
 url(r'^narrow_category/(\d+)/(\w+)/(\d+)/(\d+)/(\d+)/$',
'catalog.views.narrow_category', name="narrow_category"),

def narrow_category(request, pk, search='', size1='', size2='', size3=''):


  Page not found (404)

Request Method: GET
Request URL:http://127.0.0.1:8000/narrow_category/8/2657018///



Take a look carefully at the URL that's causing the error:

  http://127.0.0.1:8000/narrow_category/8/2657018///

does it matches any of your rules?



HTH

--
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: how do I specify optional params in url?

2013-03-31 Thread frocco
 url(r'^narrow_category/(\d+)/$', 'catalog.views.narrow_category', 
name="narrow_category"),
url(r'^narrow_category/(\d+)/(\w+)/$', 
'catalog.views.narrow_category', name="narrow_category"),
url(r'^narrow_category/(\d+)/(\w+)/(\d+)/$', 
'catalog.views.narrow_category', name="narrow_category"),
url(r'^narrow_category/(\d+)/(\w+)/(\d+)/(\d+)/$', 
'catalog.views.narrow_category', name="narrow_category"),
url(r'^narrow_category/(\d+)/(\w+)/(\d+)/(\d+)/(\d+)/$', 
'catalog.views.narrow_category', name="narrow_category"),

def narrow_category(request, pk, search='', size1='', size2='', size3=''):
 
Page not found (404)Request Method:GETRequest URL:
http://127.0.0.1:8000/narrow_category/8/2657018///

-- 
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: how do I specify optional params in url?

2013-03-31 Thread Alexis Roda

Al 31/03/13 19:00, En/na frocco ha escrit:

Hello,

Here is my current url.

url(r'^narrow_category/(\d+)/(\w*)/(\d*)/(\d*)/(\d*)/$',
'catalog.views.narrow_category', name="narrow_category"),

d+ is required
w* can be optional
last three d* can be optional

This setting is not working.


You should be a bit more explicit about what "is not working" means.

I presume that you expect that an URL like "narrow_category/23" should 
be matched against your url definition. No, it won't, since the slashes 
are not optional. All those will match against your regular expression:


  narrow_category/23/
  narrow_category/23/foo
  narrow_category/23/45
  narrow_category/23///23//

I think that the cleanest solution is defining a set of urls and, 
somehow, provide default values for the missing parts:


  def my_view(request, foo, bar="spam", baz=1234):
  pass

  url(r"^narrow/(\d+)/$", views.my_view, ...)
  url(r"^narrow/(\d+)/(\w+)/$", views.my_view, ...)
  url(r"^narrow/(\d+)/(\w+)/(\d+)/$", views.my_view, ...)

Note that the parts are no longer optional (+ instead of *).

It works like this:

  /narrow/23/
matches the 1st rule
django calls: my_view(request, "23")
the view gets the arguments: foo="23", bar="spam", baz=1234

  /narrow/23/baz/
2nd rule
my_view(request, "23", "baz")
foo="23", bar="baz", baz=1234

  /narrow/23/baz/45/
3rd rule
my_view(request, "23", "baz", "45")
foo="23", bar="baz", baz="45"

  /narrow/23/45/
2nd rule
my_view(request, "23", "45")
foo="23", bar="45", baz=1234


HTH

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




how do I specify optional params in url?

2013-03-31 Thread frocco
Hello,

Here is my current url.

   url(r'^narrow_category/(\d+)/(\w*)/(\d*)/(\d*)/(\d*)/$', 
'catalog.views.narrow_category', name="narrow_category"),

d+ is required
w* can be optional
last three d* can be optional

This setting is not working.

What am I doing wrong?

Thanks

-- 
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: How do I get these field values in my template?

2013-03-31 Thread frocco
Thank you

On Sunday, March 31, 2013 10:17:35 AM UTC-4, Alexis Roda wrote:
>
> Al 31/03/13 15:18, En/na frocco ha escrit: 
> > cat = Product.objects.values_list('category__image_path','category__id') 
> > 
> > outputs; 
> > (u'category/goodyear logo.jpg', 13) 
> > 
> > I tried for c in cat: 
> > c.image_path 
> > c.id 
>
> As its name may suggest values_lists() returns (kind) a list of lists, 
> so you must index by position, not by field name: 
>
> for c in cat: 
>  print c[0], c[1] 
>
> {% for c in cat %} 
> {{ c.0 }} {{c.1}} 
> {% endfor %} 
>
> If you want to index by field name you should use values(), which 
> returns a list of dictionaries mapping "field name" to "value". 
>
>
>
> HTH 
>

-- 
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: Filtering M2M in Admin Interface

2013-03-31 Thread Tim Cook
Answering myself, but for future searchers.
This is related to this bug report
https://code.djangoproject.com/ticket/14891  as well as this
discussion http://goo.gl/ac5lg
So for now I'll figure out a work around with QuerySets and indexes,
instead of using keys.

Cheers,
Tim

On Sat, Mar 30, 2013 at 1:40 PM, Tim Cook  wrote:
> Hi All,
>
> I have a scenario setup very much like the Polls example in the tutorial.
>
> class Terminology(models.Model):
> name = models.CharField(max_length=110)
> abbreviation = models.CharField(max_length=20)
> version = models.CharField(max_length=30)
>
> def __unicode__(self):
> return self.name + " : " + self.version
>
> class Codes(models.Model):
> terminology = models.ForeignKey(Terminology)
> code_string = models.CharField(max_length=110)
> code = models.CharField(max_length=20)
> url = models.URLField(verbose_name="Reference", help_text="An
> optional reference to the description for the code.", blank=True)
>
> def __unicode__(self):
> return self.code + " : " + self.code_string
>
>
> Now to extend this a bit.
>
> class DvCodedString(DvString):
> terminology = models.ForeignKey(Terminology, null=True, blank=True)
> codes = models.ManyToManyField(Codes, null=True, blank=True)
> ...
>
>
> My admin models:
> class CodesInline(admin.TabularInline):
> model = Codes
> extra = 5
>
> class TerminologyAdmin(admin.ModelAdmin):
> fieldsets = (
> (None, {'classes':('wide',),
>'fields':('abbreviation','version','name',)}),
> )
> inlines = [CodesInline]
> admin.site.register(Terminology, TerminologyAdmin)
>
>
> class DvCodedStringAdmin(admin.ModelAdmin):
> fieldsets = (
> (None, {'classes':('wide',),
>'fields':('published','prj_name','data_name',)}),
> ("Basic", {'classes':('collapse',),
>'fields':('terminology','codes',),
>'description':'When all codes come from one
> terminology (and one version of it).'}),
>
> ...
>
> Currently all codes will be shown in the select box.
> But of course what I really want is the Terminology Choice to filter
> the available codes displayed.
>
> So, my question is:
> Where can I find the relevant documentation on doing this in the admin
> interface?
> Or can it be done in the admin interface?
>
> Thanks,
> Tim
>
>
>
>
>
> --
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook



-- 

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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: How do I get these field values in my template?

2013-03-31 Thread Alexis Roda

Al 31/03/13 15:18, En/na frocco ha escrit:

cat = Product.objects.values_list('category__image_path','category__id')

outputs;
(u'category/goodyear logo.jpg', 13)

I tried for c in cat:
c.image_path
c.id


As its name may suggest values_lists() returns (kind) a list of lists, 
so you must index by position, not by field name:


for c in cat:
print c[0], c[1]

{% for c in cat %}
   {{ c.0 }} {{c.1}}
{% endfor %}

If you want to index by field name you should use values(), which 
returns a list of dictionaries mapping "field name" to "value".




HTH

--
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: I get import errors when I run django-admin.py startproject in Windows

2013-03-31 Thread Karen Tracey
What errors, exactly? Without some specifics of what's going wrong it's
hard to offer help. Copy/paste of exactly what you are entering and getting
in response would help.

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




How do I get these field values in my template?

2013-03-31 Thread frocco
cat = Product.objects.values_list('category__image_path','category__id')

outputs;
(u'category/goodyear logo.jpg', 13) 

I tried for c in cat:
c.image_path
c.id

Thanks

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




I get import errors when I run django-admin.py startproject in Windows

2013-03-31 Thread Brek Cooney
I get import errors when I run django-admin.py startproject for the first 
time in Windows 7. I installed Django 1.5.1 and I am trying to use that 
with Python 3.3. Any ideas about how to get past this hurdle? I am new to 
Django.

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




my project is not working in virtualenv in ubuntu?

2013-03-31 Thread Avnesh Shakya
hi,
   please tell me,what is issue with me, I am using virtualenv in ubuntu, i 
am fine in window,but here it's not showing admin pages,
   I have installed apache2 and wsgi, i want to run my project through my 
own apache2.but its not showing 
my pages-
/var/www/mydomain.com/index.py  

import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/DJ/local/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('/home/avnProject/avnProject')
sys.path.append('/home/avnProject/avnProject/avnproject')

os.environ['DJANGO_SETTINGS_MODULE'] = 'avnproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

AND
second file is-- path
/etc/apache2/sites-available/mydomain.com


ServerAdmin avn...@techhue.com
ServerName localhost
ServerAlias mydomain.com
WSGIScriptAlias / var/www/mydomain.com/index.wsgi

Alias /static/ /var/www/mydomain.com/static/

Options -Indexes



Myproject directory is  /home/avin/avnProject/

please help me
i m trying localhost/mydomain.com then fine when I put 
localhost/mydomain.com/index.wsgi,then it's downloading it..
and i m unable to open admin page here


Thanks in advance...
 


-- 
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: Question about documentauion under Managers>Adding extra Manager methods

2013-03-31 Thread Russell Keith-Magee
Unless I'm mistaken, it's PostgreSQL. The telling feature is the GROUP BY
clause - PostgreSQL allows you to group by column index.

http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-GROUPBY

Since this is an eccentricity of PostgreSQL, it would be a good idea for us
to modify that example in the docs, and use a more conventional GROUP BY
statement that would be familiar to all SQL dialects. I've opened ticket
#20168 to track this issue.

Yours,
Russ Magee %-)

On Sun, Mar 31, 2013 at 5:49 AM, James Durham wrote:

> In this instance, what I'm asking is about the documentation.
> In other words does anyone recognize the dialect.
> It would just help in understanding docs.
> Though, thanks for indicating that it is backend dependent.
>
> On Friday, March 29, 2013 8:40:09 PM UTC-5, Russell Keith-Magee wrote:
>
>>
>>
>> On Sat, Mar 30, 2013 at 6:20 AM, James Durham wrote:
>>
>>> In the example:
>>>
>>> class PollManager(models.Manager):
>>> def with_counts(self):
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute("""SELECT p.id, p.question, p.poll_date, 
>>> COUNT(*)FROM polls_opinionpoll p, polls_response r
>>> WHERE p.id = r.poll_idGROUP BY 1, 2, 3ORDER BY 3 
>>> DESC""")
>>> result_list = []
>>> for row in cursor.fetchall():
>>> p = self.model(id=row[0], question=row[1], poll_date=row[2])
>>> p.num_responses = row[3]
>>> result_list.append(p)
>>> return result_list
>>> class OpinionPoll(models.Model):
>>> question = models.CharField(max_length=20**0)
>>> poll_date = models.DateField()
>>> objects = PollManager()
>>> class Response(models.Model):
>>> poll = models.ForeignKey(OpinionPoll)
>>> person_name = models.CharField(max_length=50**)
>>> response = models.TextField()
>>>
>>> What is the sql dialect that is used.
>>>
>>> In this case you're opening a cursor, so you use whatever dialect your
>> database uses. If you're using PostgreSQL, use PostgreSQL syntax; if you're
>> using MySQL, use MySQL syntax.
>>
>> Django's ORM hides syntax differences from you; but once you start
>> dealing with database cursors or raw() queries, you're coding right to the
>> metal, so your deployment environment matters.
>>
>> Yours,
>> Russ Magee %-)
>>
>>  --
> 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.
>
>
>

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