Queries to multiple tables
Hello, I'm new to Django and trying to learn it by making a simple budget/checkbook application. I apologize for my ignorance, but I couldn't seem to find an answer to this on Google or the Django docs from my searches. I want to create a function that will take a bank account as an id number (assumed to already exist), and the payee/amount. From there, the function will do a typical bank transaction: 1) add the entry to the "Ledger" table, and subtract the amount from the "balance" field of the "Account" table for the account referenced in the id number passed to the function. Where is the appropriate/intended place to put that type of function? Model, Manager, View, or somewhere completely different? My best guess is that it belongs in a Manager, but all of the examples I can find seem to indicate that Managers are intended for queries. Thanks in advance, Kris -- 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: google app engine suggestion
thank you javier, i am a .net and php developer, i can setup .net and php servers on windows, ubuntu. i am new to django/python. i love python so giving it a try. can you give any idea of setting up my own django server, i found hard time in setting up one. not able to choose between apache and nginx mod_wsgi, mod_python. i never found a decent documentation on how to setup and run django on apache or nginx. With Best -Ashwin. +91-9959166266 On Fri, Nov 9, 2012 at 11:24 PM, Javier Guerra Giraldezwrote: > On Fri, Nov 9, 2012 at 11:53 AM, Aswani Kumar > wrote: > > my question is google app engine supports python 2.7 but django moving > > towards python 3.x now with django 1.5 the minimum required version of > > python is 2.6. and django 1.6 will be on python 2.7. what will be my > future > > if i choose google app engine and django. > > migration to 3.x is still experimental, it will be some time before > it's mandatory. > > also, a significant part of Django deprecation policy is which > versions are available in widely used platforms. Not so long ago, 2.4 > was still supported just because some still-supported RHEL version > uses it by default. > > finally, i'm sure Google will make 3.x available before 2.7 is > hopelessly obsolete. Remember that they employ some big-name Python > developers just for that (even someone with GvR initials) > > > > i need a PAAS like google app engine so i can concentrate on developing > app > > instead of managing servers. > > personally, i find much easier to manage my own server than to be > constantly distracted by the by-design limitations of the different > PaaS offerings. But if you find one that you really like, and don't > mind the lock-in, go for it! > > > -- > Javier > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Hi guyz . iam just a beginner in google app engine..plz help me "abt deleting datas from DATASTORE"
muhammed riyas wrote: > hi, > while trying to delete the datas from the datastore it shows the > error... > > > > > BadArgumentError at /employee/removeall/ Expected an instance or iterable > of (, 'google.appengine.api.datastore_types.Key'>, ); > received object at 0xb090aac>> (a instancemethod). Request Method: GET Request > URL: > http://localhost:9778/employee/removeall/ Exception Type: > BadArgumentError Exception Value: Expected an instance or iterable of > (, 'google.appengine.api.datastore_types.Key'>, ); > received object at 0xb090aac>> (a instancemethod). Exception Location: > /home/user/google_appengine/google/appengine/api/datastore.py in > NormalizeAndTypeCheck, line 148 > > //in my view > > from ITISMYAPP.main.models import Employeeprofile > from google.appengine.ext import db > def removeall(request): > employees =Employeeprofile.all().fetch(2000) > employeekeys = [] > for employee in employees: > employeekeys.append(employee.key) > db.delete(employeekeys) > return render_to_response('main/index.html') > > i dont know why? > > > > > Hello, Your question isn't related to Django, so it is not suitable for this group. You should send questions about App Engine software to an App Engine-related group. Having said that, the error message that you are getting is telling you that your employeekeys list does not contain keys, it contains references to the key method of each Employee instance in your query resultset. You need to change the line employeekeys.append(employee.key) to employeekeys.append(employee.key()) Now your list will contain the keys. Cheers, Kev -- 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.
CBV for Nested Formesets
I'm looking at these two blog posts to help me figure out nested formsets: http://yergler.net/blog/2009/09/27/nested-formsets-with-django/ http://andreipetre.tumblr.com/post/26203496689/nested-formsets-with-django The example uses a function view and I was interested using class-based views, but I can't figure out where to start. Thanks for any pointers. - Lee -- 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: google app engine suggestion
On Fri, Nov 9, 2012 at 11:53 AM, Aswani Kumarwrote: > my question is google app engine supports python 2.7 but django moving > towards python 3.x now with django 1.5 the minimum required version of > python is 2.6. and django 1.6 will be on python 2.7. what will be my future > if i choose google app engine and django. migration to 3.x is still experimental, it will be some time before it's mandatory. also, a significant part of Django deprecation policy is which versions are available in widely used platforms. Not so long ago, 2.4 was still supported just because some still-supported RHEL version uses it by default. finally, i'm sure Google will make 3.x available before 2.7 is hopelessly obsolete. Remember that they employ some big-name Python developers just for that (even someone with GvR initials) > i need a PAAS like google app engine so i can concentrate on developing app > instead of managing servers. personally, i find much easier to manage my own server than to be constantly distracted by the by-design limitations of the different PaaS offerings. But if you find one that you really like, and don't mind the lock-in, go for it! -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to build this query
That looks correct, though you don't need distinct('id'), since presumably id is your primary key and will already be unique. _Nik On 11/9/2012 1:01 AM, ozgur yilmaz wrote: > Maybe: > paris_discounts = Discount.objects.filter( brand__shop__city__name = > 'Paris' ).distinct('id') > > What do you think? > > 2012/11/9 ozgur yilmaz: >> But Brand doesnt have a city field. Shop class has a city field. >> >> 2012/11/9 Jirka Vejrazka : >>> paris_discounts = Discount.objects.filter(brand__city__name='Paris') ? >>> >>> Note that these are always *double* underscores and I had to make a guess >>> that your City has an attribute "name". >>> >>> HTH >>> >>> Jirka >>> >>> >>> >>> On Fri, Nov 9, 2012 at 9:12 AM, ozgur yilmaz wrote: Hi all, I hope i can explain my query problem well. Think you have 3 classes: class City( models.Model ): ... ... class Brand( models.Model ): ... ... class Shop( models.Model ): brand = models.ForeignKey( Brand ) city = models.ForeignKey( City ) ... ... class Discount( models.Model ): brand = models.ForeignKey( Brand ) ... ... Think a Shop sell products of a single Brand. I have lots of Discount records. But i'm interested in Discounts at Shops in Paris. Is there any? Can you help me? Thanks, -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
google app engine suggestion
hi, i am planning to develop an education related information portal in django and google app engine. my question is google app engine supports python 2.7 but django moving towards python 3.x now with django 1.5 the minimum required version of python is 2.6. and django 1.6 will be on python 2.7. what will be my future if i choose google app engine and django. i need a PAAS like google app engine so i can concentrate on developing app instead of managing servers. please give me suggestions. -- 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/-/yO-kbOlbht8J. 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 crop image ?
The only thing I didn't like about easy-thumbnails is that it relied on generating them on the fly and caching them, if I remember correctly. While that's not totally horrendous, I was using a CDN and didn't want to use my Django Application to serve media. Note: I might be thinking of something else (sorl?) so my apologies if I've given incorrect information. On Fri, Nov 9, 2012 at 9:56 AM, Brentwrote: > Have you looked at easy-thumbnails? It depends on PIL or Pillow and works > great for cropping amount other image manipulations. > > -- > 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/-/-8PoiC9kdKYJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: tutorial first step. -ImportError: No module named django.core-
I am sure I activated the environment but nothing. In my case I guess I had some problem with the PATH variable.. 2012/11/9 Dan Gentry> Quick note: when using virutalenv on Windows, one runs the activate script > to use the environment. \Scripts\activate.bat > > Same function as the source command in Linux. > > Dan Gentry > > >>> -- > 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/-/Msx_DI0lDi8J. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to crop image ?
Have you looked at easy-thumbnails? It depends on PIL or Pillow and works great for cropping amount other image manipulations. -- 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/-/-8PoiC9kdKYJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: tutorial first step. -ImportError: No module named django.core-
Quick note: when using virutalenv on Windows, one runs the activate script to use the environment. \Scripts\activate.bat Same function as the source command in Linux. Dan Gentry >> -- 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/-/Msx_DI0lDi8J. 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: Hi guyz . iam just a beginner in google app engine..plz help me "abt deleting datas from DATASTORE"
On Friday, 9 November 2012 11:33:53 UTC, muhammed riyas wrote: > > hi, > while trying to delete the datas from the datastore it shows the > error... > > > > > BadArgumentError at /employee/removeall/ Expected an instance or iterable > of (, 'google.appengine.api.datastore_types.Key'>, ); received > object at 0xb090aac>> (a instancemethod). Request Method: GET Request > URL: http://localhost:9778/employee/removeall/ Exception Type: > BadArgumentError Exception Value: Expected an instance or iterable of > (, 'google.appengine.api.datastore_types.Key'>, ); received > object at 0xb090aac>> (a instancemethod). Exception Location: > /home/user/google_appengine/google/appengine/api/datastore.py > in NormalizeAndTypeCheck, line 148 > > //in my view > > from ITISMYAPP.main.models import Employeeprofile > from google.appengine.ext import db > def removeall(request): > employees =Employeeprofile.all().fetch(2000) > employeekeys = [] > for employee in employees: > employeekeys.append(employee.key) > db.delete(employeekeys) > return render_to_response('main/index.html') > > i dont know why? > > You should ask AppEngine questions on the relevant AppEngine group, not here, as this is not a Django question. But your problem is that `.key` is a method, not an attribute, so you should call it: `employee.key()`. -- DR. -- 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/-/RpHts8wg3igJ. 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: login using an external database
On Fri, Nov 9, 2012 at 7:21 PM, Lucas Nunes ''Ruivinhoshow''wrote: > i mean db = database > >> >> uhmm... but the second app isn't in django. it was built in php I >> think... or it doesn't matter? > > > the important is: I have access to a database that is part of another > application and want to use the login fields from there to log into my > system .. a database for two apps I don't know exactly, but this may help you: Describe the two databases in the settings file like: DATABASES = { 'default': { 'NAME': 'app_data', 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'USER': 'postgres_user', 'PASSWORD': 's3krit' }, 'users': { 'NAME': 'user_data', 'ENGINE': 'django.db.backends.mysql', 'USER': 'mysql_user', 'PASSWORD': 'priv4te' } } -- Satinderpal Singh http://satindergoraya.blogspot.in/ http://satindergoraya91.blogspot.in/ -- 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: Consume Web Service
Thanks Tim. After mulling it over I decided to go with SUDS and so far all is working like a charm. On Thursday, November 8, 2012 4:52:11 PM UTC-5, Tim Sawyer wrote: > > I keep it simple and just create the XML manually. Works for me on > simple services. > > > http://drumcoder.co.uk/blog/2009/nov/23/running-soap-webservice-without-library/ > > > Tim. > > On 08/11/12 21:26, Derrick Jackson wrote: > > Hi all, > > > > I have a web service that I need to consume. Do you have > > any recommendations as to what I should be using to consume it? > > SoapLIb, Suds, etc... > > > > -- > > 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/-/wHxZM3GF5ysJ. > > To post to this group, send email to > > django...@googlegroups.com. > > > To unsubscribe from this group, send email to > > django-users...@googlegroups.com . > > For more options, visit this group at > > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sBRBb02To6kJ. 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: login using an external database
i mean db = database > uhmm... but the second app isn't in django. it was built in php I > think... or it doesn't matter? > the important is: I have access to a database that is part of another application and want to use the login fields from there to log into my system .. a database for two apps -- 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/-/fF5PL45UgYsJ. 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: more problems than one
ok, that was not really useful for me... :( -- 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/-/k8IF1Joy_GcJ. 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: login using an external database
On Fri, Nov 9, 2012 at 6:02 PM, Lucas Nunes ''Ruivinhoshow''wrote: > hi, i'm brazilian (sorry for dude engl.. xD ). I want to login an user using > the tables that exists in other db... What do you mean by other db, > i'll need the tables named 'matricula' and 'password', and so i log on > this user in my app... If you want to join the two application databases, use the following query. from django.appName import TableName -- Satinderpal Singh http://satindergoraya.blogspot.in/ http://satindergoraya91.blogspot.in/ -- 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.
login using an external database
hi, i'm brazilian (sorry for dude engl.. xD ). I want to login an user using the tables that exists in other db... i'll need the tables named 'matricula' and 'password', and so i log on this user in my app... can som1 help me ? -- 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/-/HviDU6jKb8sJ. 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: more problems than one
Take a look at your urls.py from django.conf.urls import patterns, include, url from klasse.views import portal, kundendaten urlpatterns = patterns('', (r'^portal1/$', portal1), (r'^kundendaten1/$', kundendaten1) ) this means next : next urls are served : portal1/ and kundendaten1/ Take a look at https://docs.djangoproject.com/en/dev/topics/http/urls/ Also if it you would like to serve ^kundendaten1 try to add next line : (r'^kundendaten1', kundendaten1) 2012/11/9 Nebros : > And there are mor problems in the code... i marked it with: > #and the problem i have there... > > -- > 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/-/zCCvQ1J8NaUJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: more problems than one
And there are mor problems in the code... i marked it with: #and the problem i have there... -- 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/-/zCCvQ1J8NaUJ. 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: more problems than one
hmm? there is more than just one page... what do you mean tochange, and what does it make? Am Freitag, 9. November 2012 11:06:03 UTC+1 schrieb Sergiy Khohlov: > add the / at the end of your page > > 2012/11/9 Nebros> >> Good morning >> i have to many proplems by programing, thats maybe because i am new and >> my englisch is not the best... (google translator is often a bad tool...) >> >> i tryed to make a page where you can put in a name "kunde" (used as a >> filter) for the next page... >> -Portal1- >> {% include "header.html" %} >> Kunde >> {% include "header2.html" %} >> Kunde >> {% include "time.html" %} >> >> >> Anfrage >> Bitte Kundennamen eingeben >> >> >> >> >> >> >> >> >> {% include "footer.html" %} >> - >> ok, this works... but the action is a bit fail, cause he tell me that he >> cant find the next page (if you click send) Request URL: >> http://127.0.0.1:8000/portal/kundendaten1 page not found... >> here is the "kundendaten1" >> -Kundendaten1- >> {% include "header.html" %} >> Kundendaten >> {% include "header2.html" %} >> Portal >> Ausgabe Kundendaten >> {% include "time.html" %} #OK, here i tryed my first view >> {% include "sql.html" %} #And here the second one... (i know this will >> not work, but i dont know how i can make 2 includes (views) on one page) >> >> NameE-Mail >> >> '.$result['t_name'].''.$result['t_mail'].' #i >> tryed it with php, but that won't work... thats why i deleted a part of php >> >> {% include "footer.html" %} >> - >> here my urls and views...: >> -urls- >> from django.conf.urls import patterns, include, url >> from klasse.views import portal, kundendaten >> urlpatterns = patterns('', >> (r'^portal1/$', portal1), >> (r'^kundendaten1/$', kundendaten1) >> ) >> - >> -views- >> from django.shortcuts import render_to_response >> import datetime >> import pyodbc >> >> def portal1(request): >> now = datetime.datetime.now() >> return render_to_response('portal1.html', {'current_date': now}) >> >> def kundendaten1(request): >> cnxn = pyodbc.connect('DRIVER={SQL >> Server};SERVER=Severname;DATABASE=Dbname;UID=***;PWD=*') >> cursor = cnxn.cursor() >> cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x, >> tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'kunde')") >> #it works when i manually put in a "kunde", i dont know how to put in the >> sended variable >> row = cursor.fetchall() >> return render_to_response("kundendaten1.html", { 'row': row }) >> - >> You see, there are many problems... pls do not post anything like "rtfm" >> or "ask google" i didnt understood the manuals... >> thx for help. :) >> >> i use python 2.7.3 >> django 1.4.1 >> pyodbc-3.0.6.win32-py2.7 >> >> -- >> 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/-/Bp-is7zodugJ. >> To post to this group, send email to django...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> django-users...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/z35Svk32M6wJ. 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.
more problems than one
Good morning i have to many proplems by programing, thats maybe because i am new and my englisch is not the best... (google translator is often a bad tool...) i tryed to make a page where you can put in a name "kunde" (used as a filter) for the next page... -Portal1- {% include "header.html" %} Kunde {% include "header2.html" %} Kunde {% include "time.html" %} Anfrage Bitte Kundennamen eingeben {% include "footer.html" %} - ok, this works... but the action is a bit fail, cause he tell me that he cant find the next page (if you click send) Request URL: http://127.0.0.1:8000/portal/kundendaten1 page not found... here is the "kundendaten1" -Kundendaten1- {% include "header.html" %} Kundendaten {% include "header2.html" %} Portal Ausgabe Kundendaten {% include "time.html" %} #OK, here i tryed my first view {% include "sql.html" %} #And here the second one... (i know this will not work, but i dont know how i can make 2 includes (views) on one page) NameE-Mail '.$result['t_name'].''.$result['t_mail'].' #i tryed it with php, but that won't work... thats why i deleted a part of php {% include "footer.html" %} - here my urls and views...: -urls- from django.conf.urls import patterns, include, url from klasse.views import portal, kundendaten urlpatterns = patterns('', (r'^portal1/$', portal1), (r'^kundendaten1/$', kundendaten1) ) - -views- from django.shortcuts import render_to_response import datetime import pyodbc def portal1(request): now = datetime.datetime.now() return render_to_response('portal1.html', {'current_date': now}) def kundendaten1(request): cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=Severname;DATABASE=Dbname;UID=***;PWD=*') cursor = cnxn.cursor() cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad20 as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 'kunde')") #it works when i manually put in a "kunde", i dont know how to put in the sended variable row = cursor.fetchall() return render_to_response("kundendaten1.html", { 'row': row }) - You see, there are many problems... pls do not post anything like "rtfm" or "ask google" i didnt understood the manuals... thx for help. :) i use python 2.7.3 django 1.4.1 pyodbc-3.0.6.win32-py2.7 -- 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/-/Bp-is7zodugJ. 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 build this query
Maybe: paris_discounts = Discount.objects.filter( brand__shop__city__name = 'Paris' ).distinct('id') What do you think? 2012/11/9 ozgur yilmaz: > But Brand doesnt have a city field. Shop class has a city field. > > 2012/11/9 Jirka Vejrazka : >> paris_discounts = Discount.objects.filter(brand__city__name='Paris') ? >> >> Note that these are always *double* underscores and I had to make a guess >> that your City has an attribute "name". >> >> HTH >> >> Jirka >> >> >> >> On Fri, Nov 9, 2012 at 9:12 AM, ozgur yilmaz wrote: >>> >>> Hi all, >>> >>> I hope i can explain my query problem well. Think you have 3 classes: >>> >>> class City( models.Model ): >>> ... >>> ... >>> >>> class Brand( models.Model ): >>> ... >>> ... >>> >>> class Shop( models.Model ): >>>brand = models.ForeignKey( Brand ) >>>city = models.ForeignKey( City ) >>> ... >>> ... >>> >>> class Discount( models.Model ): >>>brand = models.ForeignKey( Brand ) >>> ... >>> ... >>> >>> Think a Shop sell products of a single Brand. I have lots of Discount >>> records. But i'm interested in Discounts at Shops in Paris. Is there >>> any? >>> >>> Can you help me? >>> >>> Thanks, >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to build this query
But Brand doesnt have a city field. Shop class has a city field. 2012/11/9 Jirka Vejrazka: > paris_discounts = Discount.objects.filter(brand__city__name='Paris') ? > > Note that these are always *double* underscores and I had to make a guess > that your City has an attribute "name". > > HTH > > Jirka > > > > On Fri, Nov 9, 2012 at 9:12 AM, ozgur yilmaz wrote: >> >> Hi all, >> >> I hope i can explain my query problem well. Think you have 3 classes: >> >> class City( models.Model ): >> ... >> ... >> >> class Brand( models.Model ): >> ... >> ... >> >> class Shop( models.Model ): >>brand = models.ForeignKey( Brand ) >>city = models.ForeignKey( City ) >> ... >> ... >> >> class Discount( models.Model ): >>brand = models.ForeignKey( Brand ) >> ... >> ... >> >> Think a Shop sell products of a single Brand. I have lots of Discount >> records. But i'm interested in Discounts at Shops in Paris. Is there >> any? >> >> Can you help me? >> >> Thanks, >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to build this query
paris_discounts = Discount.objects.filter(brand__city__name='Paris') ? Note that these are always *double* underscores and I had to make a guess that your City has an attribute "name". HTH Jirka On Fri, Nov 9, 2012 at 9:12 AM, ozgur yilmazwrote: > Hi all, > > I hope i can explain my query problem well. Think you have 3 classes: > > class City( models.Model ): > ... > ... > > class Brand( models.Model ): > ... > ... > > class Shop( models.Model ): >brand = models.ForeignKey( Brand ) >city = models.ForeignKey( City ) > ... > ... > > class Discount( models.Model ): >brand = models.ForeignKey( Brand ) > ... > ... > > Think a Shop sell products of a single Brand. I have lots of Discount > records. But i'm interested in Discounts at Shops in Paris. Is there > any? > > Can you help me? > > Thanks, > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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 build this query
Hi all, I hope i can explain my query problem well. Think you have 3 classes: class City( models.Model ): ... ... class Brand( models.Model ): ... ... class Shop( models.Model ): brand = models.ForeignKey( Brand ) city = models.ForeignKey( City ) ... ... class Discount( models.Model ): brand = models.ForeignKey( Brand ) ... ... Think a Shop sell products of a single Brand. I have lots of Discount records. But i'm interested in Discounts at Shops in Paris. Is there any? Can you help me? Thanks, -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.