Re: Form formatting
This works: label {font-weight: normal;} th {text-align: right;} On Jan 28, 11:32 am, Zeynel wrote: > Thanks. I added the CSS to the template; but it is not working. What > am I doing wrong? > > > > Feedback > > label {font-weight: none} > th {align: right} > > > > {% include 'menu.html' %} > > > > {{ form.as_table }} > > > > > > > > On Jan 28, 11:04 am, Rick Caudill wrote: > > > > > Use CSS. > > > label {font-weight: none} > > th {align: left} > > > On Thu, Jan 28, 2010 at 9:53 AM, Zeynel wrote: > > > Hello, > > > > How can I remove the bold in this formhttp://swimswith.com/feedback/ > > > and fix the alignment? > > > > 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-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com > > groups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > Rick Caudill -- 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: Form formatting
Thanks. I added the CSS to the template; but it is not working. What am I doing wrong? Feedback label {font-weight: none} th {align: right} {% include 'menu.html' %} {{ form.as_table }} On Jan 28, 11:04 am, Rick Caudill wrote: > Use CSS. > > label {font-weight: none} > th {align: left} > > > > > > On Thu, Jan 28, 2010 at 9:53 AM, Zeynel wrote: > > Hello, > > > How can I remove the bold in this formhttp://swimswith.com/feedback/ > > and fix the alignment? > > > 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-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > groups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > Rick Caudill -- 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.
Form formatting
Hello, How can I remove the bold in this form http://swimswith.com/feedback/ and fix the alignment? 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-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: Number of total items in the database
Thanks. That works. On Jan 27, 1:26 pm, Malcolm Box wrote: > On Wed, Jan 27, 2010 at 6:10 PM, Zeynel wrote: > > Hello, > > > How do I query the the total number of items in the database to put in > > a template? > > > I want to add to this pagehttp://swimswith.com/search/that "There > > are currently [X] lawyers in the database." > > Have a look at the count() method on Querysets. > > So something like: Lawyers.objects.count() will be the answer. > > Cheers, > > Malcolm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Number of total items in the database
Hello, How do I query the the total number of items in the database to put in a template? I want to add to this page http://swimswith.com/search/ that "There are currently [X] lawyers in the database." 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-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: Chaining queries?
I answered my own question: http://stackoverflow.com/questions/2058573/how-to-refine-an-initial-query-in-django Any improvements and suggestions are welcome. On Jan 13, 1:36 pm, Zeynel wrote: > I am using this query in the views function search() to find a lawyer > in the database: > > lawyers = Lawyer.objects.filter(last__icontains=q) > > q is the query entered by user here:http://swimswith.com/search-form/ > > For instance, searching for "lelland" returns her > info:http://swimswith.com/search/?q=delelle > > But instead of returning that info, I want to grab the school info and > year_graduated for "delelle" and search again and find all lawyers who > graduated from the same school the same year and display that. Can > anyone help about how to do this? > > This is the view > > def search(request): > if 'q' in request.GET and request.GET['q']: > q = request.GET['q'] > lawyers = Lawyer.objects.filter(last__icontains=q) > return render_to_response('search_results.html', {'lawyers': > lawyers, 'query': q}) > else: > return HttpResponse('Please submit a search term.') > > This is the model: > > from django.db import models > > class Lawyer(models.Model): > firm_url = models.CharField('Bio', max_length=200) > firm_name = models.CharField('Firm', max_length=100) > first = models.CharField('First Name', max_length=50) > last = models.CharField('Last Name', max_length=50) > year_graduated = models.IntegerField('Year graduated') > school = models.CharField(max_length=300) > > class Meta: > ordering = ('last',) > def __unicode__(self): > return self.first > > Also in > stackoverflow:http://stackoverflow.com/questions/2058573/how-to-refine-an-initial-q... > > Thanks for your help! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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.
Chaining queries?
I am using this query in the views function search() to find a lawyer in the database: lawyers = Lawyer.objects.filter(last__icontains=q) q is the query entered by user here: http://swimswith.com/search-form/ For instance, searching for "lelland" returns her info: http://swimswith.com/search/?q=delelle But instead of returning that info, I want to grab the school info and year_graduated for "delelle" and search again and find all lawyers who graduated from the same school the same year and display that. Can anyone help about how to do this? This is the view def search(request): if 'q' in request.GET and request.GET['q']: q = request.GET['q'] lawyers = Lawyer.objects.filter(last__icontains=q) return render_to_response('search_results.html', {'lawyers': lawyers, 'query': q}) else: return HttpResponse('Please submit a search term.') This is the model: from django.db import models class Lawyer(models.Model): firm_url = models.CharField('Bio', max_length=200) firm_name = models.CharField('Firm', max_length=100) first = models.CharField('First Name', max_length=50) last = models.CharField('Last Name', max_length=50) year_graduated = models.IntegerField('Year graduated') school = models.CharField(max_length=300) class Meta: ordering = ('last',) def __unicode__(self): return self.first Also in stackoverflow: http://stackoverflow.com/questions/2058573/how-to-refine-an-initial-query-in-django Thanks for your help! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Referencing the view function in urlpatterns
Thanks. This may be it. I'll try it later. But does that also explain why in the dev server the reference is not a string but in the production server it is a string? On Jan 13, 12:23 pm, Tim Miller wrote: > Zeynel wrote: > > I created a view function for a search form and put it in my views.py > > like this: > > > (r'^search-form/$', views.search_form), > > > This worked fine in the development server. > > > When I did the same in the production server I got an 500 server > > error. Then I realized that the reference to view should be string, > > like this: > > > (r'^search-form/$', 'sw1.wkw1.views.search_form'), > > > Can you help me understand the logic here? Which one is the correct > > way? Thanks. > > Just a guess but could the code on your production server be missing an > import statement? > > Like... from sw1 import wkw1 -- 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.
Referencing the view function in urlpatterns
I created a view function for a search form and put it in my views.py like this: (r'^search-form/$', views.search_form), This worked fine in the development server. When I did the same in the production server I got an 500 server error. Then I realized that the reference to view should be string, like this: (r'^search-form/$', 'sw1.wkw1.views.search_form'), Can you help me understand the logic here? Which one is the correct way? 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-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.
Search filter and sort in one step?
I want to improve the search function in the admin. I asked the same question both here and in stackoverflow previously but there were no answers: http://stackoverflow.com/questions/2029310/django-admin-search Does anyone know if this is impossible to do? 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-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: Clickable url in the admin
Thank you. Can you give me more detailed instructions about how to do this? I couldn't parse the referenced section of the documentation. How do I create the method "to generate anchor?" Where does the "method name" go in the admin.py? Thanks again. On Dec 14, 6:41 pm, rebus_ wrote: > Create method on your model that generates anchor (html link tag) > which points to wanted URL and put that methods name in list_display > property of AdminModel object in your admin.py > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri... -- 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: Clickable url in the admin
I found this thread: http://groups.google.com/group/django-users/msg/11b034152c9dff1a Does anyone have more details on urlize? On Dec 14, 1:16 pm, Zeynel wrote: > In my models I have this field > > firm_url = models.CharField('Bio', max_length=200) > > that should have a link to the website where the lawyer bio is. This > is in the admin. I thought that > > firm_url = models.URLField('Bio', max_length=200) > > would make the url appear as a link; but it doesn't; documentation > says URLField is a CharField. So how do I make this url clickable in > the admin? 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-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.
Clickable url in the admin
In my models I have this field firm_url = models.CharField('Bio', max_length=200) that should have a link to the website where the lawyer bio is. This is in the admin. I thought that firm_url = models.URLField('Bio', max_length=200) would make the url appear as a link; but it doesn't; documentation says URLField is a CharField. So how do I make this url clickable in the admin? 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-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.
Is there a way to display the admin filters in two columns?
This is what I have now in admin.py class LawyerAdmin(admin.ModelAdmin): fieldsets = [ ('Name', {'fields': ['first', 'last', 'firm_name', 'firm_url', 'school', 'year_graduated']}), #('School', {'fields': ['school', 'year_graduated']}), ] list_display = ('first', 'last', 'school', 'year_graduated', 'firm_name', 'firm_url') list_filter = ['school', 'year_graduated'] search_fields = ['last', 'school', 'firm_name'] Is it possible to display 'school' in one column and 'year_graduated' in another column? I tried list_display = ('first', 'last', 'school', 'year_graduated', 'firm_name', 'firm_url') list_filter = ['school'] list_filter = ['year_graduated'] search_fields = ['last', 'school', 'firm_name'] but that doesn't work. -- 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: The best way to populate sqlite3 database
On Dec 12, 3:04 pm, Shawn Milochik wrote: > > http://pastebin.com/f651cf8de Hi, Thanks for the script, I want to use it but I have some questions. These are from the previous thread: http://groups.google.com/group/django-users/msg/091f964c6c8e40c7 but I have others as well. Thanks again. -- 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: CSV to JSON snippet
This is fixed by modifying lines 31-32: http://stackoverflow.com/questions/1894099/csv2json-py-error On Dec 10, 3:12 pm, Zeynel wrote: > This worked fine before but now I get the error > > C:\...\Django\sw2\wkw2>csv2json.py csvtest1.csvwkw2.Lawyer > Converting C:\...\Django\sw2\wkw2csvtest1.csvfromCSVto JSON as C:... > \Django\sw2\wkw2csvtest1.csv.json > Traceback (most recent call last): > File "C:\...\Django\sw2\wkw2\csv2json.py", line 37, in > f = open(in_file, 'r' ) > IOError: [Errno 2] No such file or directory: 'C:\\...\\Django\\sw2\ > \wkw2cvtest1.csv' > > From the snippethttp://www.djangosnippets.org/snippets/1680/: > > 31 in_file = dirname(__file__) + input_file_name > 32 out_file = dirname(__file__) + input_file_name + ".json" > > 34 print "Converting %s fromCSVto JSON as %s" % (in_file, out_file) > > 36 f = open(in_file, 'r' ) > 37 fo = open(out_file, 'w') > > It seems to combine the directory name and file name? > > Thanks. > > On Nov 14, 7:42 am, Zeynel wrote: > > > > > Great, thank you. When I ran it in the command prompt it worked fine. > > I noticed that the first column needs to be "pk" with rows starting > > with integers. > > > On Nov 13, 11:24 pm, Karen Tracey wrote: > > > > On Fri, Nov 13, 2009 at 10:57 PM, Zeynel wrote: > > > > Thanks, I tried but this did not work either: > > > > > >>> csv2json.py sw.csvwkw1.Lawyer > > > > > File "", line 1 > > > > csv2json.py sw.csvwkw1.Lawyer > > > > ^ > > > > SyntaxError: invalid syntax > > > > You need to run the .py script from an OS shell (command prompt), not from > > > within a Python shell. > > > > Karen -- 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.
The best way to populate sqlite3 database
Hi, I first put the data in csv format than convert it to json and then create a fixture... which seems a long process. This http://stackoverflow.com/questions/1884694/how-to-populate-sqlite3-in-django/1885417#1885417 answer suggests to "Just load the database directly," but without giving much practical info. Can anyone here help? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Looking for guidance on django-registration
I think this will be in the documentation of your hosting co, for instance, http://docs.webfaction.com/software/django.html#configuring-django-to-send-email-messages On Dec 12, 11:51 am, vishy wrote: > got the registration working.Now, how to setup activation email? > > On Dec 12, 9:41 pm, vishy wrote: > > > > > I have downloaded the latest module.Now,I need to set it up.I want > > guidance,especially how to setup the templates, like what goes into > > registration_form.html.If there is some source code that will be > > great. > > 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-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: Can I change the models.py of an existing django app?
Shawn, Since I did not want to save the data I deleted the db file and ran synchdb and that created a new database. But eventually I will use south because I will keep adding new columns to this database. Thanks. On Dec 11, 7:50 pm, Shawn Milochik wrote: > I feel like a broken record this week -- I've been recommending South in > every other post I've made on this list. > > So, at risk of annoying people, check out South:http://south.aeracode.org > > It does exactly what you want it to do, and is the dominant (and nearly the > only) solution used in the Django community. > > Shawn -- 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: Can I change the models.py of an existing django app?
On Dec 11, 5:23 pm, Nick Arnett wrote: > If you don't need to save your existing data, the easiest thing is to drop > the old database and re-create it, then let syncdb create all the tables > again. Yes, I deleted the content of the sqlite3 database file and then ran syncdb and it created the new database. 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-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: Can I change the models.py of an existing django app?
On Dec 11, 2:42 pm, "bax...@gretschpages.com" wrote: > If the table already exists, you will need to manually modify it. For > sqlite3, I would suggest the Firefox sqllite manager plugin, which > makes editing the tables pretty easy. You are right. I did upload the new models.py and run python2.5 manage.py synchdb and then ./reset but I am getting TemplateSyntaxError: no such column: wkw1_lawyer.firm_url so the new columns were not created. I will have to just start from scratch and create a new project. -- 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: Can I change the models.py of an existing django app?
On Dec 11, 1:52 pm, "bax...@gretschpages.com" wrote: > On Dec 11, 12:21 pm, Zeynel wrote: > > syncdb will not alter an existing database. You can run it (it won't > hurt) but it won't insert the new fields. I am confused about this because the django documentation here http://docs.djangoproject.com/en/dev/intro/tutorial01/#activating-models says that, >> Now, run syncdb again to create those model tables in your database: >> python manage.py syncdb >> The syncdb command runs the sql from 'sqlall' on your database >> for all apps in INSTALLED_APPS that don't already exist in your database. >> This creates all the tables, initial data and indexes for any apps >> you have added to your project since the last time you ran syncdb. >> syncdb can be called as often as you like, >> and it will only ever create the tables that don't exist. ^^ So, it seems that, according to documentation, syncdb will create the new tables? I am using sqlit3, by the way. > You'll need to go to your > database, either through the command line or through a tool like > phpmyadmin and add the new fields manually. You can, however, run > manage.py sql YOURAPP to see what the table should look like. -- 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: Can I change the models.py of an existing django app?
On Dec 11, 1:21 pm, Phlip wrote: > What does manage.py syncdb do? I think it sets up the new database: http://stackoverflow.com/questions/1889622/how-to-replace-models-py-in-django-app-in-the-production-server/1889650#1889650 -- 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: Can I change the models.py of an existing django app?
Ok. What else do I need to do after uploading the new models.py with new fields to the server and run manage.py syncdb? On Dec 11, 12:50 pm, "bax...@gretschpages.com" wrote: > On Dec 11, 11:39 am, Zeynel wrote: > > > I just want to add 2 new fields to the model. If I upload the new > > models.py would the app work as before? > > Yes, but you'll have to manually adjust your database to have the new > fields. -- 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.
Can I change the models.py of an existing django app?
I just want to add 2 new fields to the model. If I upload the new models.py would the app work as before? I asked the same question in OS that includes the models. Thanks for the help. http://stackoverflow.com/questions/1889622/how-to-replace-models-py-in-django-app-in-the-production-server -- 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: CSV to JSON snippet
This worked fine before but now I get the error C:\...\Django\sw2\wkw2>csv2json.py csvtest1.csv wkw2.Lawyer Converting C:\...\Django\sw2\wkw2csvtest1.csv from CSV to JSON as C:... \Django\sw2\wkw2csvtest1.csv.json Traceback (most recent call last): File "C:\...\Django\sw2\wkw2\csv2json.py", line 37, in f = open(in_file, 'r' ) IOError: [Errno 2] No such file or directory: 'C:\\...\\Django\\sw2\ \wkw2cvtest1.csv' >From the snippet http://www.djangosnippets.org/snippets/1680/: 31 in_file = dirname(__file__) + input_file_name 32 out_file = dirname(__file__) + input_file_name + ".json" 34 print "Converting %s from CSV to JSON as %s" % (in_file, out_file) 36 f = open(in_file, 'r' ) 37 fo = open(out_file, 'w') It seems to combine the directory name and file name? Thanks. On Nov 14, 7:42 am, Zeynel wrote: > Great, thank you. When I ran it in the command prompt it worked fine. > I noticed that the first column needs to be "pk" with rows starting > with integers. > > On Nov 13, 11:24 pm, Karen Tracey wrote: > > > > > On Fri, Nov 13, 2009 at 10:57 PM, Zeynel wrote: > > > Thanks, I tried but this did not work either: > > > > >>> csv2json.py sw.csvwkw1.Lawyer > > > > File "", line 1 > > > csv2json.py sw.csvwkw1.Lawyer > > > ^ > > > SyntaxError: invalid syntax > > > You need to run the .py script from an OS shell (command prompt), not from > > within a Python shell. > > > Karen -- 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: How to populate the database
I tried to convert my csv file with csv2json.py and it worked before (see this thread http://groups.google.com/group/django-users/browse_frm/thread/a00b529ba2147d91/efb82ba2893cc0a7?lnk=gst&q=csv#efb82ba2893cc0a7) but now I am trying the same exact thing in a different directory and I get this error: C:\...\Django\sw2\wkw2>csv2json.py csvtest1.csv wkw2.Lawyer Converting C:...\Django\sw2\wkw2csvtest1.csv from CSV to JSON as C:\...\Django\sw2\wkw2csvtest1.csv.json Traceback (most recent call last): File "C:\...\Django\sw2\wkw2\csv2json.py", line 37, in f = open(in_file, 'r' ) IOError: [Errno 2] No such file or directory: 'C:\\...\\Django\\sw2\\wkw2csvtest1.csv' Below is the link to csv2jason.py and line 37: http://www.djangosnippets.org/snippets/1680/ ... in_file = dirname(__file__) + input_file_name out_file = dirname(__file__) + input_file_name + ".json" print "Converting %s from CSV to JSON as %s" % (in_file, out_file) [line 37] --> f = open(in_file, 'r' ) fo = open(out_file, 'w') Do you know an easier way to convert csv to json? (Or how to fix this?) On Dec 10, 1:27 pm, John M wrote: > You could also use OpenOffice with the SQLIte connector (I think) > > I use Access in Windows, works great! > > But you might try getting the CSV into a JSON format that the > manage.py loaddata command could use, that set's you up for the future > too. > > J > > On Dec 10, 8:57 am, Zeynel wrote: > > > > > Can anyone point me in the right place in documentation for populating > > my sqlite3 tables with the data in the .csv file? 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-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: How to populate the database
Thanks, I'll try it now. What does os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' do? I read the documentation here http://docs.python.org/library/os.html but I didn't understand. My app is in C:.../Documents/PROJECTS/Django/sw2/wkw2. Do I enter? os.environ['DJANGO_SETTINGS_MODULE'] = 'sw2.settings'? from sw2.wkw2.models import School, Lawyer By INPUT_FILE you mean the file where data I want to upload to sqlite3 is, correct? That file is sw2/csvtest1.csv What's 'Internal ID'? This is my models.py: from django.db import models class School(models.Model): school = models.CharField(max_length=300) def __unicode__(self): return self.school class Lawyer(models.Model): firm_url = models.URLField('Bio', max_length=200) firm_name = models.CharField('Firm', max_length=100) first = models.CharField('First Name', max_length=50) last = models.CharField('Last Name', max_length=50) year_graduated = models.IntegerField('Year graduated') school = models.CharField(max_length=300) school = models.ForeignKey(School) class Meta: ordering = ('?',) def __unicode__(self): return self.first Thanks! On Dec 10, 12:56 pm, Shawn Milochik wrote: > Sure, here's a quick & dirty sample I put up on pastebin: > > http://pastebin.com/f651cf8de -- 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: How to populate the database
Thanks. I couldn't make the sqlite3 shell work on windows command prompt, so I cannot use .import. > read the csv with csv.DictReader, then create instances of my model > with the values from the resulting dictionary, then calling a .save() on > the new instance. Do you have more detailed instructions on this method? On Dec 10, 12:08 pm, Shawn Milochik wrote: > There are different ways to do it, depending on how much data you have and > how often you plan to do it. > > The fastest way for large files is to use sqlite3's .import command to > directly import a file. However, this will bypass any validation done by your > models. > > The way I do it is to read the csv with csv.DictReader, then create instances > of my model with the values from the resulting dictionary, then calling a > .save() on the new instance. This is fairly slow, but thorough; you won't > realize belatedly that your database is missing required fields or has > invalid values, because the script will just blow up if you try. > > Shawn -- 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.
How to populate the database
Can anyone point me in the right place in documentation for populating my sqlite3 tables with the data in the .csv file? 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-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.
Using admin search as keyword search?
I asked this in Stackoverflow but there was no answers: http://stackoverflow.com/questions/1849250/django-admin-search-functionality Can anyone here help with ways to achieve this: I have a simple database in django with SQLite and now I want to improve it with a better search capability (I will create a new project with new models). I would like to ask about how to plan and go about this project. The existing database has these fields: first, initial, last, school, yearGraduated I am using django admin to sort by last name and then filter by year graduated to find lawyers who graduated from same school the same year. It works like this: Enter last name and search. Search results reveal all lawyers who went to same school Sort by last name searched Find year graduated Go to year graduated filter and click on the year graduated to get his classmates. Example: Search for "connelly" Results for 58 names who went to Georgetown University Law Center Sort by last name to see that connelly graduated in 1973 Click on 1973 in year graduated filter This pulls 3 more lawyers "eliot", "frederick" and "alan" who graduated from Georgetown in 1973 Instead of this I would like to enter "connelly" in the search box and get the names of "eliot", "frederic" and "alan". I am planning to use Postgres with these fields: url (of the bio page of lawyer); firm; firstName; lastName; school; yearGraduated How do I achieve this result? Thanks for your advice and help. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Redirect problems
Adam and Skylar, The ISP's support just replied to my ticket. They set the urls.py as urlpatterns = patterns('', (r'^wkw1/$', 'sw1.wkw1.views.index'), (r'^admin/$', 'django.views.generic.simple.redirect_to', {'url': '/ admin/wkw1/lawyer'}), (r'^admin/wkw1/$', 'django.views.generic.simple.redirect_to', {'url': '/admin/wkw1/lawyer'}), (r'^admin/', include(admin.site.urls)), ) and this is now working. But looking at the example in the documentation http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-simple-redirect-to urlpatterns = patterns('django.views.generic.simple', ('^foo/(?P\d +)/$', 'redirect_to', {'url': '/bar/%(id)s/'}),) I see that it is a little different. I am confused because I don't exactly understand how urlpatterns works. I hope to read about it more, e.g., I found this document with lots of examples: http://www.scribd.com/doc/4975790/urlpatterns-for-django-cheatsheet Thanks for the help. On Nov 18, 11:09 am, Skylar Saveland wrote: > What are the details of the error? > > On Nov 18, 7:06 am, Zeynel wrote: > > > > > I've been trying to redirect > > > /admin/ to /admin/wkw1/lawyer > > > The suggestions from my previous > > posthttp://groups.google.com/group/django-users/msg/67c4594a4083bd45 > > did not work. > > > I read the redirect section in the documents as suggested > > >http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-... > > > and tried this urls.py > > > from django.conf.urls.defaults import * > > from django.contrib import admin > > admin.autodiscover() > > > urlpatterns = patterns('', > > (r'^wkw1/$', 'sw1.wkw1.views.index'), > > # (r'^admin/', include(admin.site.urls)), > > ) > > > urlpatterns += patterns('django.views.generic.simple', > > ('^admin/$', 'redirect_to', {'url': '/admin/wkw1/lawyer/'}), > > ) > > > but this too results in a server error. > > > Any suggestions? > > > 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-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=.
Redirect problems
I've been trying to redirect /admin/ to /admin/wkw1/lawyer The suggestions from my previous post http://groups.google.com/group/django-users/msg/67c4594a4083bd45 did not work. I read the redirect section in the documents as suggested http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-simple-redirect-to and tried this urls.py from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^wkw1/$', 'sw1.wkw1.views.index'), #(r'^admin/', include(admin.site.urls)), ) urlpatterns += patterns('django.views.generic.simple', ('^admin/$', 'redirect_to', {'url': '/admin/wkw1/lawyer/'}), ) but this too results in a server error. Any suggestions? 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-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=.
Re: Can I change the title of an admin page?
This worked, thanks. But I had to change base.html as well (in ~/webapps/django/sw1/ templates/admin). Because previously I had hardcoded the {{ title }} in line 65 in base.html {% block content_title %}{% if title %}{{ title }}{% endif %} {% endblock %} I would like to ask, if you can help me understand how this line 65 gets the document title and if I can change the document title. Because I prefer that {{ title }} remains there. I actually want to make http://swimswith.com/admin/wkw1/ private because I don't want the reviewers of the demo to see that page. I am having problems with views as well so I'll ask that in another thread. Thank you for the help On Nov 17, 12:45 pm, lzantal wrote: > Don't copy the original change_list.html file over there. > Create a new empty change_list.html file and put the code in there I > posted previusly. > So your new file will have only 2 lines of code inside. > What it does is it extends the original template and thanks to django > blocks you overwrite the title section. > > lzantalhttp://twitter.com/lzantal > > On Nov 17, 6:46 am, Zeynel wrote: > > > > > Ok, thanks. I read the "overriding admin templates" section. I want to > > learn Django's template system and all these files are confusing to > > me, but eventually I'll get it. > > > As instructed I created the directory system > > > ~/webapps/django/sw1/templates/admin/wkw1/lawyer > > > Then, I copied change_list.html from > > > django/contrib/admin/templates/admin > > > and pasted it in > > > ~/webapps/django/sw1/templates/admin/wkw1/lawyer > > > Then I copied > > > {% extends "admin/change_list.html" %} > > {% block content_title %}Your Title Here{% endblock %} > > > and pasted on top of change_list.html. > > > I restarted the server. But I don't see the change. What am I doing > > wrong? > > > Thanks again for your help. > > > On Nov 17, 8:57 am, Karen Tracey wrote: > > > > On Tue, Nov 17, 2009 at 8:46 AM, Zeynel wrote: > > > > I am sorry, I am new to django and I don't understand what I need to > > > > do here. > > > > You should read this section in the docs: > > > >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad... > > > > Karen -- 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=.
Re: Can I change the title of an admin page?
Ok, thanks. I read the "overriding admin templates" section. I want to learn Django's template system and all these files are confusing to me, but eventually I'll get it. As instructed I created the directory system ~/webapps/django/sw1/templates/admin/wkw1/lawyer Then, I copied change_list.html from django/contrib/admin/templates/admin and pasted it in ~/webapps/django/sw1/templates/admin/wkw1/lawyer Then I copied {% extends "admin/change_list.html" %} {% block content_title %}Your Title Here{% endblock %} and pasted on top of change_list.html. I restarted the server. But I don't see the change. What am I doing wrong? Thanks again for your help. On Nov 17, 8:57 am, Karen Tracey wrote: > On Tue, Nov 17, 2009 at 8:46 AM, Zeynel wrote: > > I am sorry, I am new to django and I don't understand what I need to > > do here. > > You should read this section in the docs: > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad... > > Karen -- 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=.
Re: Can I change the title of an admin page?
I am sorry, I am new to django and I don't understand what I need to do here. Do I create a new template file eg, mytemplate.html, in the directory templates/wkw1/lawyer/mytemplates.html and copy and paste in it {% extends "admin/change_list.html" %} {% block content_title %}Your Title Here{% endblock %} My templates are in sw1/templates/admin Thank you for your help. On Nov 16, 9:56 pm, lzantal wrote: > Hi, > > In your templates/wkw1/lawyer dir extend change_list.html and override > the title:: > {% extends "admin/change_list.html" %} > {% block content_title %}Your Title Here{% endblock %} > > Hope it helps > > lzantalhttp://twitter.com/lzantal > > On Nov 16, 5:31 pm, Zeynel wrote: > > > > > RIDER 2: > > > pictures of the title I want to change: > > >http://zeynel.posterous.com/django-template-problem > > > On Nov 16, 3:35 pm, Zeynel wrote: > > > > In case someone else has the same problem: I hard-coded the text I > > > wanted in between h1 tags in template base.html. > > > > {% block content_title %}{% if title %}Enter last name{% > > > endif %}{% endblock %} > > > > but this defeats the purpose of templates. If you know how titles are > > > created in django, please let me know. > > > > On Nov 16, 2:57 pm, Zeynel wrote: > > > > > I found that the base.html template takes the title in admin change > > > > page from the title of the page: > > > > > line 64 in base.html: > > > > > {% block content_title %}{% if title %}{{ title }}{% endif %} > > > > {% endblock %} > > > > > How can I change the title of the page? Does anyone know? > > > > > Also mentioned here:http://code.djangoproject.com/changeset/1975 -- 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=.
Re: Can I change the title of an admin page?
RIDER 2: pictures of the title I want to change: http://zeynel.posterous.com/django-template-problem On Nov 16, 3:35 pm, Zeynel wrote: > In case someone else has the same problem: I hard-coded the text I > wanted in between h1 tags in template base.html. > > {% block content_title %}{% if title %}Enter last name{% > endif %}{% endblock %} > > but this defeats the purpose of templates. If you know how titles are > created in django, please let me know. > > On Nov 16, 2:57 pm, Zeynel wrote: > > > > > I found that the base.html template takes the title in admin change > > page from the title of the page: > > > line 64 in base.html: > > > {% block content_title %}{% if title %}{{ title }}{% endif %} > > {% endblock %} > > > How can I change the title of the page? Does anyone know? > > > Also mentioned here:http://code.djangoproject.com/changeset/1975 -- 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=.
Re: Default sort order in admin
Yes, this is probably true. I am still learning. And I like Django and how it works but it takes time to understand some concepts. I was rushing a little bit because I wanted to meet this challenge >> [the tutorial] is enough to build it in no longer that a few days (learning >> included), >> even for pre-intermediate programmer. mentioned here: http://groups.google.com/group/django-users/browse_frm/thread/d7f9320f3fba5df0/cfd37dc8d5d51027?q=#cfd37dc8d5d51027 But it took me 2 weeks to finish this very simple app. And I'm still trying to resolve this last issue. If you look at the pictures here http://zeynel.posterous.com/django-template-problem the title "Search lawyer by last name" should not be in the /admin/ wkw1 directory because the search box is in /admin/wkw1/lawyer/. How do I change that title? On Nov 16, 5:55 pm, Daniel Roseman wrote: > On Nov 16, 4:31 pm, Zeynel wrote: > > > > > > > Thanks! > > > I noticed that using > > > class Lawyer(models.Model): > > ... > > ordering = ('last',) > > > did not work. > > > But this worked > > > class Lawyer(models.Model): > > ... > > class Meta: > > ordering = ('last',) > > > copied fromhttp://www.djangoproject.com/documentation/models/ordering/ > > > What is the correct way actually? > > You weren't reading closely enough. The page Karen linked you to is > all about admin options, and that option therefore belongs on the > ModelAdmin class, not the model itself. The other page explains how > you set the default ordering for a model throughout the application, > which the admin will also use if it doesn't have anything else set. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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=.
Re: Can I change the title of an admin page?
In case someone else has the same problem: I hard-coded the text I wanted in between h1 tags in template base.html. {% block content_title %}{% if title %}Enter last name{% endif %}{% endblock %} but this defeats the purpose of templates. If you know how titles are created in django, please let me know. On Nov 16, 2:57 pm, Zeynel wrote: > I found that the base.html template takes the title in admin change > page from the title of the page: > > line 64 in base.html: > > {% block content_title %}{% if title %}{{ title }}{% endif %} > {% endblock %} > > How can I change the title of the page? Does anyone know? > > Also mentioned here:http://code.djangoproject.com/changeset/1975 -- 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=.
Can I change the title of an admin page?
I found that the base.html template takes the title in admin change page from the title of the page: line 64 in base.html: {% block content_title %}{% if title %}{{ title }}{% endif %} {% endblock %} How can I change the title of the page? Does anyone know? Also mentioned here: http://code.djangoproject.com/changeset/1975 -- 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=.
Re: Disabling site wide actions
EDIT: In the page source code the title that I want to change shows like this: Select lawyer to change Where do i find this class="flex" ? On Nov 16, 1:34 pm, Zeynel wrote: > Django rocks! I used disable a site-wide action as explained here > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#disab... > > but now I have the title "Select a lawyer to change" just above my > search box. The action box is gone, but it's title is still there. Can > anyone please help me to change that title to "Search lawyers" ? > > Thank you -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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=.
Disabling site wide actions
Django rocks! I used disable a site-wide action as explained here http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#disabling-a-site-wide-action but now I have the title "Select a lawyer to change" just above my search box. The action box is gone, but it's title is still there. Can anyone please help me to change that title to "Search lawyers" ? Thank you -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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=.
Changing the admin templates
My app is almost done but before I send it out to get some feedback I want to make a couple of more design tweaks. I changed the branding on the login dialogue box and on the dark blue band on top, by changing the template base_site.html. On the home page (www.swimswith.com/admin/) I want to change the title "Site administration" and on the change page (www.swimswith.com/admin/ wkw1/lawyer) I want to change the title "Select lawyer to change". I went through each template in the directory /webapps/django/lib/python2.5/django/contrib/admin/templates/admin but could not see any similar text to change. Can anyone help about finding the right template? 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-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=.
Re: Default sort order in admin
Thanks! I noticed that using class Lawyer(models.Model): ... ordering = ('last',) did not work. But this worked class Lawyer(models.Model): ... class Meta: ordering = ('last',) copied from http://www.djangoproject.com/documentation/models/ordering/ What is the correct way actually? On Nov 16, 10:22 am, Karen Tracey wrote: > On Mon, Nov 16, 2009 at 10:11 AM, Zeynel wrote: > > Hi, > > > Is there a way to change the default sort order in admin of my sqlite > > db? At this point it sorts the table in the order entered (last > > entered item first). > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri... > > Karen -- 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=.
Default sort order in admin
Hi, Is there a way to change the default sort order in admin of my sqlite db? At this point it sorts the table in the order entered (last entered item first). 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-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=.
Re: setup python, django for web development
This site has instructions http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First_App that appear to be simpler than the official django tutorial http://docs.djangoproject.com/en/dev/intro/install/#intro-install On Nov 16, 1:20 am, harshad wrote: > hello All, > > Im new to python, django. Can anyone help me as to how to do the setup > on windows so that i can start developing web based applications on > python. > > regards > harshad -- 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=.
Re: Auth and Sites in Admin
Great, thanks. That solves my problem. But, I wish it were possible to actually make a user read only. Unless I give the user the right to change content the admin page says, "You don't have permission to edit anything" and no content is visible. But overall, I think admin is really great tool and there is still a lot to learn. On Nov 15, 9:22 pm, Alex Robbins wrote: > Those sections won't show up for anyone who doesn't have edit > permissions. As long as you don't give the admin user superuser status > or permissions for those apps they won't show up. > > On Nov 14, 6:34 pm, Zeynel wrote: > > > > > Is it possible to remove "Auth" and "Sites" sections from the Admin > > panel? -- 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=.
Re: Redirect
I couldn't make this one work: ('^$', lambda *args: HttpResponseRedirect('/admin/')) I want to try the other case, which file in apache do I use? Thanks On Nov 15, 1:01 pm, Dennis Kaarsemaker wrote: > On zo, 2009-11-15 at 09:35 -0800, Zeynel wrote: > > > how do i redirectwww.swimswith.comtowww.swimswith.com/admin/ > > In your urlpatterns: > ('^$', lambda *args: HttpResponseRedirect('/admin/')) > > Or make your webserver do this, e.g. in apache: > > RewriteEngine On > RewriteRule ^/$ /admin/ [R,L] > > -- > Dennis K. > > The universe tends towards maximum irony. Don't push it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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=.
Redirect
hello, how do i redirect www.swimswith.com to www.swimswith.com/admin/ 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-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=.
Auth and Sites in Admin
Is it possible to remove "Auth" and "Sites" sections from the Admin panel? -- 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=.
Re: New user login problem
I figured that "active" and "staff" need to be checked as explained here: http://docs.djangoproject.com/en/dev/faq/admin/ Does anybody know how to make admin "view only" for a user? This paragraph from the above appears to explain a similar process: How do I limit admin access so that objects can only be edited by the users who created them? The ModelAdmin class also provides customization hooks that allow you to control the visibility and editability of objects in the admin. Using the same trick of extracting the user from the request, the ModelAdmin.queryset() and ModelAdmin.has_change_permission() can be used to control the visibility and editability of objects in the admin. Is there anyone who is familiar with this process? On Nov 14, 9:38 am, Zeynel wrote: > Hello, > > I am creating a new user successfully but I cannot login with that new > user. I make sure that username and pw (case sensitive) are correct. > Is there more to creating a new user? -- 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=.
New user login problem
Hello, I am creating a new user successfully but I cannot login with that new user. I make sure that username and pw (case sensitive) are correct. Is there more to creating a new user? -- 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=.
Re: CSV to JSON snippet
Great, thank you. When I ran it in the command prompt it worked fine. I noticed that the first column needs to be "pk" with rows starting with integers. On Nov 13, 11:24 pm, Karen Tracey wrote: > On Fri, Nov 13, 2009 at 10:57 PM, Zeynel wrote: > > Thanks, I tried but this did not work either: > > > >>> csv2json.py sw.csv wkw1.Lawyer > > > File "", line 1 > > csv2json.py sw.csv wkw1.Lawyer > > ^ > > SyntaxError: invalid syntax > > You need to run the .py script from an OS shell (command prompt), not from > within a Python shell. > > Karen -- 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=.
Re: CSV to JSON snippet
Thanks, I tried but this did not work either: >>> csv2json.py sw.csv wkw1.Lawyer File "", line 1 csv2json.py sw.csv wkw1.Lawyer ^ SyntaxError: invalid syntax >>> I checked "stdin" but I didn't understand how it relates to this case: http://en.wikibooks.org/wiki/Python_Programming/Input_and_output http://stackoverflow.com/questions/1450393/how-do-you-read-from-stdin-in-python On Nov 13, 1:36 pm, BenChapman wrote: > At line 21 of csv2json.py, change "import simplejson" to "from > django.utils import simplejson" > > Now try running the csv2json.py script from the command line: > > python csv2json.py sw.csv wkw1.Lawyer > > See if that solves the problem. > > Best, > > Ben > > On Nov 12, 2:14 pm, Zeynel wrote: > > > > > Hi, > > > my project is in C:/sw1/wkw1 > > models are in C:/sw1/wkw1/models.py > > > Model name is Lawyer. > > > So, in the python shell I import simplejson with > > > from django.utils import simplejson > > > then I enter > > > csv2json.py sw.csv wkw1.Lawyer > > > and I get the error > > > >>> from django.utils import simplejson > > >>> csv2json.py sw.csv wkw1.Lawyer > > > File "", line 1 > > csv2json.py sw.csv wkw1.Lawyer > > ^ > > SyntaxError: invalid syntax > > > What am I doing wrong? > > > On Nov 12, 1:57 pm, "R. Gorman" wrote: > > > > What is the error message you are receiving? > > > > R. -- 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=.
Debugging loaddata
Since my attempt to use sqlcustom to insert some data into my SQLite3 database failed I was trying to use a JSON fixture. But when I tried it, I got this traceback. Can anyone help me locate these files so that I can understand what the error is? (I don't know where to find the referenced files) Thank you. --- Installing json fixture 'f1' from 'C:\sw1\..\sw1\wkw1\fixtures'. Problem installing fixture 'C:\sw1\..\sw1\wkw1\fixtures\f1.json': Traceback (most recent call last): File "C:\Python26\Lib\site-packages\django\core\management\commands \loaddata.py", line 150, in handle for obj in objects: File "C:\Python26\lib\site-packages\django\core\serializers \json.py", line 41, in Deserializer for obj in PythonDeserializer (simplejson.load(stream)): File "C:\Python26\lib\site-packages\django\core\serializers \python.py", line 9 5, in Deserializer data[field.attname] = field.rel.to._meta.get_field(field.rel.field_name).to_ python(field_value) File "C:\Python26\lib\site-packages\django\db\models\fields \__init__.py", line 356, in to_python_("This value must be an integer.")) ValidationError: This value must be an integer. -- 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=.
Re: sqlcustom
I found these two previous queries: http://groups.google.com/group/django-users/browse_thread/thread/e692a073b88c15f2?fwc=1 Does anyone know what is "rest" subcommand? http://groups.google.com/group/django-users/browse_frm/thread/da4601114a82635b/359e6d294f5faed7?lnk=gst&q=sqlcustom#359e6d294f5faed7 On Nov 13, 9:51 am, Zeynel wrote: > I am trying to add some records to my SQLite3 database with sqlcustom > as explained > herehttp://docs.djangoproject.com/en/dev/ref/django-admin/#ref-django-admin > > I don't get any errors when I run > > C:\sw1>manage.py sqlcustom wkw1 > > BEGIN; > INSERT INTO mkw1_lawyer (first, initial, last, year_graduated, school) > VALUES ('Christian', '', 'Abel', '2006', 'University of Hamburg'); > INSERT INTO mkw1_lawyer (first, initial, last, year_graduated, school) > VALUES ('Daniel', 'M.', 'Abuhoff', '1978', 'Columbia Law School'); > COMMIT; > > C:\sw1>manage.py syncdb > > But the values are not actually added to the database. Does anyone > know what I am doing wrong? > > Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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=.
sqlcustom
I am trying to add some records to my SQLite3 database with sqlcustom as explained here http://docs.djangoproject.com/en/dev/ref/django-admin/#ref-django-admin I don't get any errors when I run C:\sw1>manage.py sqlcustom wkw1 BEGIN; INSERT INTO mkw1_lawyer (first, initial, last, year_graduated, school) VALUES ('Christian', '', 'Abel', '2006', 'University of Hamburg'); INSERT INTO mkw1_lawyer (first, initial, last, year_graduated, school) VALUES ('Daniel', 'M.', 'Abuhoff', '1978', 'Columbia Law School'); COMMIT; C:\sw1>manage.py syncdb But the values are not actually added to the database. Does anyone know what I am doing wrong? Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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=.
Re: Apache2 installation
Yes, finally the support decided to install it. The process was a nightmare. I don't know if this is the same with other hosting places. The documentation was horrible and just outlining the process for people who are experts, not for newbies. And now they installed the project in 2 different directories: /home/zeynel/sw1 and /home/webapps/ django/sw1. I kept changing the settings.py in /home/sw1 DEBUG = False, and resetting the server, and nothing was happening. I found that I needed to change the settings.py here: /home/webapps/django/sw1 So that's done and hopefully that removes the debug admin page, I think this is what the django documentation advises. I have a simple database in admin but I realized that to reach the admin a username and pw is needed. I haven't figured how to translate the functionality I have in admin (database, and search) to a public webpage. If you can help I'd appreciate it. On Nov 13, 3:43 am, Francois Verbeek wrote: > http://www.swimswith.com/wkw1/returns something (SwimsWith: A Legal > Who-Knows-Who)... from the admin debug page, this is the only url defined in > your urls.py. > so it looks like working fine, except if your urls.py contains something > else, in which case, could you detail what? > > Francois > > > > - Original Message - > From: "Zeynel" > To: "Django users" > Sent: Thursday, 12 November, 2009 11:44:13 PM > Subject: Apache2 installation > > Hello, > > I've been trying to port my app to apache2 server from the django > development server. After trying all day, I now see the admin page but > I don't see my app. Hosting co is not helping because they say this is > "pure django." > > Is there someone familiar with this process and could you point me to > the right document or help if you can. > > I just copied the app directory to the apache server > > ~/webapps/django/sw1/wkw1 > > admin.py and urls.py are same. > > I connect to the server with Putty and cd to > > ~/webapps/django/sw1 > > and run > > python2.5 manage.py syncdb > > then I cd to > > ~/webapps/django/apache2/bin > > and > > ./restart > > But this has no effect. I still see the standard admin without my app. > > http://www.swimswith.com/admin/ > > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=. -- 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=.
Apache2 installation
Hello, I've been trying to port my app to apache2 server from the django development server. After trying all day, I now see the admin page but I don't see my app. Hosting co is not helping because they say this is "pure django." Is there someone familiar with this process and could you point me to the right document or help if you can. I just copied the app directory to the apache server ~/webapps/django/sw1/wkw1 admin.py and urls.py are same. I connect to the server with Putty and cd to ~/webapps/django/sw1 and run python2.5 manage.py syncdb then I cd to ~/webapps/django/apache2/bin and ./restart But this has no effect. I still see the standard admin without my app. http://www.swimswith.com/admin/ 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-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=.
Re: CSV to JSON snippet
Hi, my project is in C:/sw1/wkw1 models are in C:/sw1/wkw1/models.py Model name is Lawyer. So, in the python shell I import simplejson with from django.utils import simplejson then I enter csv2json.py sw.csv wkw1.Lawyer and I get the error >>> from django.utils import simplejson >>> csv2json.py sw.csv wkw1.Lawyer File "", line 1 csv2json.py sw.csv wkw1.Lawyer ^ SyntaxError: invalid syntax >>> What am I doing wrong? On Nov 12, 1:57 pm, "R. Gorman" wrote: > What is the error message you are receiving? > > R. -- 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=.
CSV to JSON snippet
Hello, I am trying to use this CSV to JSon Fixture snippet but I couldn't make it work. http://www.djangosnippets.org/snippets/1680/ Can anyone help me to run this snippet. I copy the instruction below. Thank you. -- The instructions for csv2json.py To run script csv2json.py input_file_name model_name e.g. csv2json.py airport.csv app.airport.Airport Note: input_file_name should be a path relative to where this script is. Scripts depends on simplejson module. The module can just be placed in a sub-folder to the script to make it easier to import. If you use the same Python binary that you use for your Django site, you could use the Django import instead: from django.utils import simplejson -- 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=.
Re: admin.site.register() - help
> does this post have anything to do with the subject of the previous post? Yes, but I wasn't sure if the indentation would cause the problem encountered by neridaj. In my screen I saw that neridaj had wrong indent for the code about unicode line. And thanks for the suggestion to try the code on IDE. Here's the result: >>> class SearchKeyword(models.Model): keyword = models.CharField(max_length=50) page = models.ForeignKey(FlatPage) def __unicode__(self): return self.keyword File "", line 4 def __unicode__(self): ^ IndentationError: unindent does not match any outer indentation level >>> class SearchKeyword(models.Model): keyword = models.CharField(max_length=50) page = models.ForeignKey(FlatPage) def __unicode__(self): return self.keyword The ide gives an error when def __unicode__(self): return self.keyword has no indent as the op had. On Nov 11, 11:09 pm, Kenneth Gonsalves wrote: > On Thursday 12 Nov 2009 9:36:11 am Zeynel wrote: > > > Sorry, I am a beginner but I noticed that in my models the indent of > > unicode is indented like this: > > > class SearchKeyword(models.Model): > > keyword = models.CharField(max_length=50) > > page = models.ForeignKey(FlatPage) > > def __unicode__(self): > > return self.keyword > > > I have no idea if this will cause an error, though. > > does this post have anything to do with the subject of the previous post? if > not, it is a good idea to start a new thread with a proper subject line. I do > not see any error in indentation, but the best way to check is to press > 'compile' on your ide and see if any errors show - indentation errors will > show. > -- > regards > Kenneth Gonsalves > Senior Project Officer > NRC-FOSShttp://nrcfosshelpline.in/web/ -- 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=.
Re: admin.site.register() - help
Sorry, I am a beginner but I noticed that in my models the indent of unicode is indented like this: class SearchKeyword(models.Model): keyword = models.CharField(max_length=50) page = models.ForeignKey(FlatPage) def __unicode__(self): return self.keyword I have no idea if this will cause an error, though. On Nov 11, 10:56 pm, Kenneth Gonsalves wrote: > On Thursday 12 Nov 2009 9:10:04 am neridaj wrote: > > > I'm doing something wrong when I try to register models for the admin > > interface and I'm not sure what it is. I have everything in my > > installed apps, is there something wrong with these files? > > it would be a good idea also to mention what error you are getting > -- > regards > Kenneth Gonsalves > Senior Project Officer > NRC-FOSShttp://nrcfosshelpline.in/web/ -- 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=.
Re: problems registering models in admin
My models.py was in the path, C:/sw1/wkw/models.py I had to include sw1: from sw1.wkw1.models import Lawyer I don't if this is true in your case as well. On Nov 11, 8:19 pm, neridaj wrote: > I'm working on a standalone app and when I try to add it to the admin > index it does not show up using: > > from django.contrib import admin > from blog.models import Category > > admin.site.register(Category) > > Thanks, > > J -- 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=.
Re: A simple database project
Ok, I tried search_fields = ['school__lawyer_first'] and I get this error Cannot resolve keyword 'lawyer_first' into field. Choices are: id, lawyer, school In the variations that I tried only search_fields = ['school__school'] worked. I followed the tutorial and arranged lawyer names as a list, so that when I search for school, I see which lawyers went to that school and their year of graduation. Then I have the filter by year, and when I apply that filter, I see all the lawyers who graduated from same school same year. This is the result that I want, but obviously not a very elegant solution. Thank you. On Nov 11, 1:01 pm, "pjrhar...@gmail.com" wrote: > > I tried > > > search_fields = ['school__lawyer'] > > > but I get an error message when I did a search for last name of > > lawyer: > > > Related Field has invalid lookup: icontains > > You need something like: > > search_fields = ['school__lawyer_last'] > > to specify which field on the related 'lawyer' instance you want to > search. You can add others like: > > search_fields = ['school__lawyer_last', 'school__lawyer_first'] > > Peter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Adding a second search box to admin panel?
Hello, I have almost what I wanted to achieve. At least enough for a demo. It works like this: Enter a law school, say "NYU" The search results show First, Initial, Last, School, Year Graduated Then I click the desired year in the Filter for "Year Graduated" and I can see all lawyers who graduated from NYU in 2000. But I want to improve this so that I start from the name of the lawyer, instead of school. So if the lawyer is Gary Y. Lawyer4, I search for Lawyer4 and find the school he went to and the date he graduated. Then I search for school to find for other lawyers who went to same school. So, is there a way to add a second search box to admin panel to search a different field? (Note: is there a way to publish the development server that I am working on now so that I can show you the app?) Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A simple database project
In this document http://docs.djangoproject.com/en/dev/ref/contrib/admin/ ModelAdmin.search_fields is explained: "You can also perform a related lookup on a ForeignKey with the lookup API "follow" notation. search_fields = ['foreign_key__related_fieldname']" I tried search_fields = ['school__lawyer'] but I get an error message when I did a search for last name of lawyer: Related Field has invalid lookup: icontains When I try search_fields = ['school__last'] I get the error message Cannot resolve keyword 'last' into field. Choices are: id, lawyer, school Maybe I don't understand what "related_fieldname" is. What is it? This is my model: class School(models.Model): school = models.CharField(max_length=200) def __unicode__(self): return self.school class Lawyer(models.Model): first = models.CharField(max_length=20) initial = models.CharField(blank=True, max_length=2) last = models.CharField(max_length=20) year_graduated = models.IntegerField('Year graduated') school = models.CharField(max_length=200) school = models.ForeignKey(School) def __unicode__(self): return self.first Thank you On Nov 10, 7:35 pm, Kenneth Gonsalves wrote: > On Wednesday 11 Nov 2009 5:51:00 am Zeynel wrote:> So I want to enter in the > search box "Lawyer1" and in the result page > > I want to see "Lawyer1 knows Lawyer2" > > if your school is a foreign key (I think it is) you need a related name to > search for that. Check out ModelAdmin.search_fields in the docs. Not sure that > this is what you are looking for though. > -- > regards > Kenneth Gonsalves > Senior Project Officer > NRC-FOSShttp://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A simple database project
Hi Tomasz, I was able to build the admin page and put a search box there: class LawyerAdmin(admin.ModelAdmin): fieldsets = [ ('Name', {'fields': ['last', 'first', 'initial']}), ('School', {'fields': ['school', 'year_graduated']}), ] list_display = ('first', 'initial', 'last', 'school', 'year_graduated') list_filter = ['year_graduated'] search_fields = ['last', 'first'] This search box searches only first and last names. But what i want is a search box that finds all lawyers who went to same school. My database now contains: Tom T. Lawyer3 Columbia School of Law 2003 Bob Lawyer2 NYU 2000 JohnI Lawyer1 NYU 2000 So Lawyer1 and Lawyer2 graduated from NYU in 2000. So I want to enter in the search box "Lawyer1" and in the result page I want to see "Lawyer1 knows Lawyer2" How do I do this? Thank you so much. On Nov 7, 12:23 pm, Tomasz Zieliński wrote: > On 7 Lis, 15:58, Zeynel wrote: > > > Hello, > > > I am planning to build a demo prototype for a who-knows-who database > > for the legal profession. Database will consist of lawyer name, school > > and year graduated. Searching by lawyer name will return other lawyers > > graduated from same law school the same year. Can I build this in > > Django? How long would it take me to learn enough Django to build this > > myself? > > Of course you can build this in Django, I think that going through > tutorial: > > http://docs.djangoproject.com/en/dev/intro/tutorial01/ > > is enough to build it in no longer that a few days (learning > included), > even for pre-intermediate programmer. > > -- > Tomasz Zielińskihttp://pyconsultant.eu --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Adding a search box in admin
Hello, Thanks again for all the help. I have the admin page and I added some lawyer names and schools, now I want to add the search box. In the tutorial it says "Let's add some search capability: search_fields = ['question'] ... " Translating this to my model, I entered in admin.py search_fields = ['last'] But this did not work for me. I did not see a search box anywhere. I found these references online: http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/ http://blog.tkbe.org/archive/django-admin-search-functionality/ http://groups.google.com/group/django-users/browse_thread/thread/59a0fb0f07f1c93f/960f28867e75909d?hl=en&lnk=gst&q=search+box#960f28867e75909d but I am not sure if that's what I need to do. I need one search: I want to pull all lawyers who graduated from same school the same year. Can you give me a clue about how to do this? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: TemplateSyntaxError
Thanks. I will try what you suggested. But I am almost there with the admin, the only thing is I need to change the date format so that it takes only the year. Now DateField requires month, day and year. I tried this year_graduated = models.DateField('Year graduated', input_formats= ['%Y']) as in class Lawyer(models.Model): first = models.CharField(max_length=20) initial = models.CharField(blank=True, max_length=2) last = models.CharField(max_length=20) year_graduated = models.DateField('Year graduated', input_formats= ['%Y']) school = models.CharField(max_length=200) school = models.ForeignKey(School) def __unicode__(self): return self.first but it doesn't work. Some googling shows that I may be confusing "form" and "models" http://osdir.com/ml/DjangoUsers/2009-03/msg02593.html In that case how can I fix the DateField so that it takes only the date? Because I only need "Year Graduated" not month or day. Thanks again. On Nov 10, 9:40 am, Monika Sulik wrote: > When you execute manage.py sql wkw, the output is just how your > current models translate into SQL. To see what's actually in the > database you should do manage.py dbshell and then use whatever command > your database supports (\d wkw_lawyer in PostgreSQL and DESCRIBE > wkw_lawyer in MySQL). > > Try doing manage.py reset wkw > My guess is that the wkw_lawyer table in the database probably has a > field called education_id instead of school_id, the reset command > should drop and create the wkw_lawyer table again (like my predecessor > proposed). More about how syncdb works (and why it wouldn't have > changed education_id into school_id) > here:http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb > > And finally, you don't have to change the name of the class when you > don't like how the plural of a class name is being rendered. You can > specify the plural in the Meta class of the > model:http://docs.djangoproject.com/en/dev/topics/db/models/#meta-optionshttp://docs.djangoproject.com/en/dev/ref/models/options/#verbose-name... > > Hope that helps :) > > On Nov 10, 3:14 am, Zeynel wrote: > > > > > Hello, > > > These are my tables: > > > BEGIN; > > CREATE TABLE "wkw_school" ( > > "id" integer NOT NULL PRIMARY KEY, > > "school" varchar(200) NOT NULL > > ) > > ; > > CREATE TABLE "wkw_lawyer" ( > > "id" integer NOT NULL PRIMARY KEY, > > "first" varchar(20) NOT NULL, > > "initial" varchar(2) NOT NULL, > > "last" varchar(20) NOT NULL, > > "year_graduated" datetime NOT NULL, > > "school_id" integer NOT NULL REFERENCES "wkw_school" ("id") > > ) > > ; > > COMMIT; > > > (I changed "Education" to "School" because in the admin panel it > > showed up as "Educations". I think "Schools" makes more sense.) > > > I created the admin and I registered School and Lawyer. > > > In the admin panel School link works fine but when I click on Lawyer > > link I get a "TemplateSyntaxError at /admin/wkw/lawyer/ > > Caught an exception while rendering: no such column: > > wkw_lawyer.school_id" > > > But according to the above tables, school_id has been created. > > > I tried to add in the shell, > > > p = Lawyer(school_id=1) > > > but > > > p.save() > > > throws an error. > > > Any ideas why Lawyer link in the admin panel does not work? > > > This is the offending line on the debug page: > > > 78 {% result_list cl %} > > > Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: TemplateSyntaxError
Ok, thanks. I started over and created a new project sw1 and module wkw1, and now it all works. But now I noticed that, the "initial" field in "Lawyer" is required. But I want it to be optional. Do I need to start over again to make that change :( And also in the "Year Graduated" field I just need the year, so I need to remove, day, month, and time. How do I make these changes? There must be a way without starting over and creating a new project. Thanks. On Nov 10, 8:06 am, Daniel Roseman wrote: > On Nov 10, 12:57 pm, Zeynel wrote: > > > > > > > Hi Tim, > > > Yes, I syncdb several times. > > > C:\sw\sw>manage.py syncdb > > > C:\sw\sw>manage.py sql wkw > > > BEGIN; > > CREATE TABLE "wkw_school" ( > > "id" integer NOT NULL PRIMARY KEY, > > "school" varchar(200) NOT NULL > > ) > > ; > > CREATE TABLE "wkw_lawyer" ( > > "id" integer NOT NULL PRIMARY KEY, > > "school_id" integer NOT NULL REFERENCES "wkw_school" ("id"), > > "first" varchar(20) NOT NULL, > > "initial" varchar(2) NOT NULL, > > "last" varchar(20) NOT NULL, > > "year_graduated" datetime NOT NULL > > ) > > ; > > COMMIT; > > > C:\sw\sw> > > > On Nov 10, 5:27 am, Tim Chase wrote: > > > > > (I changed "Education" to "School" because in the admin panel it > > > > showed up as "Educations". I think "Schools" makes more sense.) > > > > Did you remember to syncdb afterwards? I'd be interested to see > > > if the SQL you showed is what the tables in the DB actually look > > > like. > > > > > Any ideas why Lawyer link in the admin panel does not work? > > > > It's on retainer? Hahahaha...sorry...a little 4:30am lawyer humor :) > > > > -tim > > syncdb does not change existing table definitions. And sql will just > show what the sql should be, not what it actually is. If you're not > using a migrations system such as South, your best bet is to drop your > tables and start again. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: TemplateSyntaxError
Hi Tim, Yes, I syncdb several times. C:\sw\sw>manage.py syncdb C:\sw\sw>manage.py sql wkw BEGIN; CREATE TABLE "wkw_school" ( "id" integer NOT NULL PRIMARY KEY, "school" varchar(200) NOT NULL ) ; CREATE TABLE "wkw_lawyer" ( "id" integer NOT NULL PRIMARY KEY, "school_id" integer NOT NULL REFERENCES "wkw_school" ("id"), "first" varchar(20) NOT NULL, "initial" varchar(2) NOT NULL, "last" varchar(20) NOT NULL, "year_graduated" datetime NOT NULL ) ; COMMIT; C:\sw\sw> On Nov 10, 5:27 am, Tim Chase wrote: > > (I changed "Education" to "School" because in the admin panel it > > showed up as "Educations". I think "Schools" makes more sense.) > > Did you remember to syncdb afterwards? I'd be interested to see > if the SQL you showed is what the tables in the DB actually look > like. > > > Any ideas why Lawyer link in the admin panel does not work? > > It's on retainer? Hahahaha...sorry...a little 4:30am lawyer humor :) > > -tim --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
TemplateSyntaxError
Hello, These are my tables: BEGIN; CREATE TABLE "wkw_school" ( "id" integer NOT NULL PRIMARY KEY, "school" varchar(200) NOT NULL ) ; CREATE TABLE "wkw_lawyer" ( "id" integer NOT NULL PRIMARY KEY, "first" varchar(20) NOT NULL, "initial" varchar(2) NOT NULL, "last" varchar(20) NOT NULL, "year_graduated" datetime NOT NULL, "school_id" integer NOT NULL REFERENCES "wkw_school" ("id") ) ; COMMIT; (I changed "Education" to "School" because in the admin panel it showed up as "Educations". I think "Schools" makes more sense.) I created the admin and I registered School and Lawyer. In the admin panel School link works fine but when I click on Lawyer link I get a "TemplateSyntaxError at /admin/wkw/lawyer/ Caught an exception while rendering: no such column: wkw_lawyer.school_id" But according to the above tables, school_id has been created. I tried to add in the shell, p = Lawyer(school_id=1) but p.save() throws an error. Any ideas why Lawyer link in the admin panel does not work? This is the offending line on the debug page: 78{% result_list cl %} Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help about models
Hello Greg and Jirka, Thanks for the help. I was rereading the tutorial to understand the ForeignKey. It says that ForeignKey "tells Django each Choice is related to a single Poll." In my case, each lawyer is associated with 1 law school; and each law school is associated with 1 or more lawyers. Considering this I thought that ForeignKey should tell Django that "each lawyer is related to a single School" so I put ForeignKey under Lawyer: class Education(models.Model): school = models.CharField(max_length=200) class Lawyer(models.Model): first = models.CharField(max_length=20) initial = models.CharField(max_length=2) last = models.CharField(max_length=20) year_graduated = models.DateTimeField('Year graduated') education = models.ForeignKey(Education) Does this make sense? And, can you explain why this is needed in terms of searching the database? What happens if I don't use a foreign key? Thanks again. On Nov 9, 7:36 am, Jirka Vejrazka wrote: > > I commented out the ForeignKey because it caused an error. > > Just a small coding note - it was causing an error because you did not > specify the model name exactly (compare the character case) > > Jirka --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Help about models
Hello, I decided to start my own project with what I learned from part 1 of the tutorial. I have the project in C:\sw\sw\wkw The app sw.wkw is a prototype for a "who-knows-who" database for legal profession. I wanted to start with a really simple model: class Lawyer(models.Model): first = models.CharField(max_length=20) initial = models.CharField(max_length=2) last = models.CharField(max_length=20) year_graduated = models.DateTimeField('Year graduated') class Education(models.Model): #lawyer = models.ForeignKey(lawyer) school = models.CharField(max_length=200) I commented out the ForeignKey because it caused an error. I will only make one search in the database. I want to enter Lawyer's name and find all other lawyers in the database who graduated from the same school the same year. It's like sorting by school in a spreadsheet and pulling the lawyer's names. Here's the sample spreadsheet: https://spreadsheets.google.com/ccc?key=0Al923jWh4O4ydG1vSmx4bDVqTUFUXzVqSXhzVkcydmc&hl=en Do you think this is the right model for what I am trying to do? Thank you for your comments. So far I created the tables and tomorrow I'll set up the admin and populate the database with some names. I am really enjoying Django. I am learning both Django and Python. Thanks again for your help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: No module named django
Selam, evet izleyecem. Guzel bir site. On Nov 8, 8:25 am, joker wrote: > Merhaba;www.djangoturkiye.comadresinden videolu eğitimlerle ders hazırladım > inceleyebilirsin > > On 8 Kasım, 00:49, Zeynel wrote: > > > > > Great! Thank you very much. I downloaded django-1.1.1 again and > > untarred again. > > > django directory is in C:\Django-1.1.1\Django-1.1.1\django > > > I don't know why I got 2 Django-1.1.1 folders but installation worked > > this time. > > > There are many __init.py__ files, they are in build directory. > > > I did the installation as "setup.py install" instead of "python > > setup.py install" so the tutorial says that django-admin.py may not be > > in the system path. > > > Now I am going to create a project. Should I create it in the second > > Django-1.1.1 folder? > > > Thanks again! > > > On Nov 7, 4:55 pm, Karen Tracey wrote: > > > > On Sat, Nov 7, 2009 at 4:15 PM, Zeynel wrote: > > > > > Hello, > > > > > I know this has been asked here a million times before, but I couldn't > > > > find the right answer. It seems something to do with PYTHONPATH. Can > > > > anyone help me figure this out. This is the error message on the > > > > windows shell: > > > > > C:\Django-1.1.1>setup.py install > > > > Traceback (most recent call last): > > > > File "C:\Django-1.1.1\setup.py", line 69, in > > > > version = __import__('django').get_version() > > > > ImportError: No module named django > > > > Is there a django directory under c:\Django-1.1.1? There should be. > > > There > > > should also be an __init__.py in that directory. If either of these are > > > missing then likely the problem is whatever tool was used to unpack the > > > tar.gz file. A tool that correctly unzips 0-byte files is required -- I've > > > seen reports before of some Windows tools not handling these properly. > > > > Karen --~--~-~--~~~---~--~~ 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: Error: No module named pollsdjango.contrib.admin
Thank you!! On Nov 8, 12:01 pm, Karen Tracey wrote: > On Sun, Nov 8, 2009 at 11:58 AM, Zeynel wrote: > > > Hi again, > > > Thanks for the help so far. > > > I am now working on the part 2 of the tutorial. > > > I updated the INSTALLED_APPS with 'django.contrib.admin': > > > INSTALLED_APPS = ( > > 'django.contrib.auth', > > 'django.contrib.contenttypes', > > 'django.contrib.sessions', > > 'django.contrib.sites', > > 'mysite.polls' > > 'django.contrib.admin' > > ) > > > You are missing a comma after 'mysite.polls' > > Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Error: No module named pollsdjango.contrib.admin
Hi again, Thanks for the help so far. I am now working on the part 2 of the tutorial. I updated the INSTALLED_APPS with 'django.contrib.admin': INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'mysite.polls' 'django.contrib.admin' ) and tried to run manage.py syncdb but I get the error Error: No module named pollsdjango.contrib.admin I am guessing this is another PATH error. Can anyone help. 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 -~--~~~~--~~--~--~---
Class definition in the tutorial
I am just learning Object Oriented terminology as I go along. Please help me to understand what each word means in the class definition in the tutorial http://docs.djangoproject.com/en/dev/intro/tutorial01/ . Thank you. class => defines a class Poll => name of the class? [my guess: this is just a name; it is not used in the database?] (models.Model): => what is this? [my guess: there is a django class called model and that has a subclass called Model and this statement says that Poll is a subcalls of Model which is subclass of model?] question => the name of the class variable? [my guess: This is a column in the database?] models. => what is this? .CharField(max_length=200) => [my guess: this defines the type of the data in the column "question"] --~--~-~--~~~---~--~~ 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: No module named django
Great! Thank you very much. I downloaded django-1.1.1 again and untarred again. django directory is in C:\Django-1.1.1\Django-1.1.1\django I don't know why I got 2 Django-1.1.1 folders but installation worked this time. There are many __init.py__ files, they are in build directory. I did the installation as "setup.py install" instead of "python setup.py install" so the tutorial says that django-admin.py may not be in the system path. Now I am going to create a project. Should I create it in the second Django-1.1.1 folder? Thanks again! On Nov 7, 4:55 pm, Karen Tracey wrote: > On Sat, Nov 7, 2009 at 4:15 PM, Zeynel wrote: > > > Hello, > > > I know this has been asked here a million times before, but I couldn't > > find the right answer. It seems something to do with PYTHONPATH. Can > > anyone help me figure this out. This is the error message on the > > windows shell: > > > C:\Django-1.1.1>setup.py install > > Traceback (most recent call last): > > File "C:\Django-1.1.1\setup.py", line 69, in > > version = __import__('django').get_version() > > ImportError: No module named django > > Is there a django directory under c:\Django-1.1.1? There should be. There > should also be an __init__.py in that directory. If either of these are > missing then likely the problem is whatever tool was used to unpack the > tar.gz file. A tool that correctly unzips 0-byte files is required -- I've > seen reports before of some Windows tools not handling these properly. > > Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
No module named django
Hello, I know this has been asked here a million times before, but I couldn't find the right answer. It seems something to do with PYTHONPATH. Can anyone help me figure this out. This is the error message on the windows shell: C:\Django-1.1.1>setup.py install Traceback (most recent call last): File "C:\Django-1.1.1\setup.py", line 69, in version = __import__('django').get_version() ImportError: No module named django I was very excited to start studying the tutorial but couldn't even install it :) Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A simple database project
Thanks. I started to study. On Nov 7, 12:23 pm, Tomasz Zieliński wrote: > On 7 Lis, 15:58, Zeynel wrote: > > > Hello, > > > I am planning to build a demo prototype for a who-knows-who database > > for the legal profession. Database will consist of lawyer name, school > > and year graduated. Searching by lawyer name will return other lawyers > > graduated from same law school the same year. Can I build this in > > Django? How long would it take me to learn enough Django to build this > > myself? > > Of course you can build this in Django, I think that going through > tutorial: > > http://docs.djangoproject.com/en/dev/intro/tutorial01/ > > is enough to build it in no longer that a few days (learning > included), > even for pre-intermediate programmer. > > -- > Tomasz Zielińskihttp://pyconsultant.eu --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
A simple database project
Hello, I am planning to build a demo prototype for a who-knows-who database for the legal profession. Database will consist of lawyer name, school and year graduated. Searching by lawyer name will return other lawyers graduated from same law school the same year. Can I build this in Django? How long would it take me to learn enough Django to build this myself? Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---