Re: Media files not served automatically anymore in 1.3?
Hope this helps: from https://docs.djangoproject.com/en/dev/releases/1.3-beta-1/ The staticfiles app ships with the ability to automatically serve static files during development (if the DEBUG setting is True) when using the runserver management command. Based on feedback from the community this release adds two new options to the runserver command to modify this behavior: --nostatic: prevents the runserver command from serving files completely. --insecure: enables serving of static files even if running with DEBUG set to False. (This is not recommended!) On Aug 25, 6:08 am, Reinout van Rees wrote: > Hi, > > I'm switching sites over to 1.3 at the moment and I only just discovered > that my media files (the media_url ones, not the new static_url ones) > aren't served anymore by the development server ("runserver"). > > The static files (static_url) *are* served automatically in DEBUG mode, > which is a nice change from django 1.2 where I had to enable > django-staticfiles' static file handling by hand. > > Now... If I look in the 1.3 change notes and follow some pointers I end > up athttps://docs.djangoproject.com/en/dev/howto/static-files/#django.conf... > > There I see an "example for serving MEDIA_URL ('/media/') during > development". That's mentioned basically as an aside. So it looks like > I'm right that the DEBUG mode media_url handing is gone now. > > Two questions: > > - "Breaking" automatic media_url serving seems worthy of a real note in > the 1.3 changelog. That note isn't there. Is this bad? Or am I missing > something? > > - Serving static_url automatically but omitting media_url is a bit > strange if you ask me. Is this a bug? > > Reinout > > -- > Reinout van Rees http://reinout.vanrees.org/ > rein...@vanrees.org http://www.nelen-schuurmans.nl/ > "If you're not sure what to do, make something. -- Paul Graham" -- 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: Could not connect postgresql database
Great job. You could've told everyone that you had a working install and decided to break it & install from source code. but oh well. OSS truly is the ultimate, when you break it you get to keep both pieces :-; For the record: why did you install from source instead of using Ubuntu packages ? A learning exercise? Bug-fix? Unwanted defaults? This might help someone in the future. Cheers/Excelsior! On 8/23/11, SSozuer wrote: > I solved the problem. I just added, >LD_LIBRARY_PATH=/usr/local/pgsql/lib >PATH=/usr/local/pgsql/bin:$PATH > > lines to my .bashrc startup shell. After that there is no error. > > Selcuk > > > On Aug 23, 10:50 pm, Landy Chapman wrote: >> I reinstalled postgresql after deleting config files. in >> postgresql.conf I changed this line: >> # listen = "localhost" >> to read: >> >> listen = "*" >> >> Also make sure this line is uncommented: >> port = 5432 >> >> Then I restarted the server. >> /etc/init.d/postgresql restart >> >> One way to see if postgresql is running would be: >> lsof | grep "postgres" >> >> > createdb conntest >> >> I asked you to create a database because if the server ISNT running >> you would not be able to. >> >> > psql -d conntest >> >> As another suggested, this will try to use the postgres client. If >> all that worked, I would've asked you to run >> >> psql -h 127.0.0.1 -d conntest >> >> Which, in a DEFAULT debian lenny install result in: >> "psql: FATAL: password authentication failed for user "postgres" >> >> I set a password for postgres: >> su >> passwd postgres >> >> Next I change pg_hba.conf to "trust" for localhost, restarted the >> server, and >> psql -h 127.0.0.1 -d conntest >> >> does work. The last step would be to use my local IP address >> psql -h 192.168.1.211 -d conntest >> >> This would make sure remote machines could connect also. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Could not connect postgresql database
I reinstalled postgresql after deleting config files. in postgresql.conf I changed this line: # listen = "localhost" to read: listen = "*" Also make sure this line is uncommented: port = 5432 Then I restarted the server. /etc/init.d/postgresql restart One way to see if postgresql is running would be: lsof | grep "postgres" > createdb conntest I asked you to create a database because if the server ISNT running you would not be able to. > psql -d conntest As another suggested, this will try to use the postgres client. If all that worked, I would've asked you to run psql -h 127.0.0.1 -d conntest Which, in a DEFAULT debian lenny install result in: "psql: FATAL: password authentication failed for user "postgres" I set a password for postgres: su passwd postgres Next I change pg_hba.conf to "trust" for localhost, restarted the server, and psql -h 127.0.0.1 -d conntest does work. The last step would be to use my local IP address psql -h 192.168.1.211 -d conntest This would make sure remote machines could connect also. -- 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: Could not connect postgresql database
Ignore my long-winded rant/reply above. the command should be psql -d test2db Cheers -- 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: Could not connect postgresql database
> there are lots of questions about this problem on net , but there is > no point solution There's no FixItNow(tm) text that works for all use cases. Sometimes over-familiarity will cause maddening (though simple-to-fix) problems. My basic point is, since nothing you did solved the problem, help us be systematic. We need to examine things step by step. So please do what we ask and post the results. I'm not talking down to you; this is basic troubleshooting. I don't even know what OS you are running. (Linux, I presume?) Your already posted pg_hba.conf file looks fine. If you want help you must provide ALL information we ask for, or we'll be shooting in the dark. Are you running linux? What distro? Are django, postgresql and pgadmin all running on the same machine? Answer the above, and post your postgresql.conf file. Then I/we can be more specific in narrowing down this problem. -- 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: Could not connect postgresql database
I apologize.. What user are you running psql as? Try this: cd /tmp su postgres createdb conntest psql -d conntest That should since you can connect from pgadmin. If it doesn't. run (as root) /etc/init.d/postgresql force-restart and try the above again. On the django side, I would check settings.py for something like this: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgr... 'NAME': 'conntest', # Or path to database file if using sqlite3. 'USER': 'postgres', # Not used with sqlite3. 'PASSWORD': 'mypgpass', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT':'5432', # Set to empty string for default. Not used with sqlite3. } } On Aug 23, 1:53 pm, SSozuer wrote: > i am taking error below: > > psql: could not connect to server: No such file or directory > Is the server running locally and accepting > connections on Unix domain socket "/var/run/postgresql/.s.PGSQL. > 5432"? > > but there is no such a .s.PGSQL.5432 file. I really dont understand > what is going on > > Selcuk > > On Aug 23, 8:12 pm, Subhranath Chunder wrote: > > > > > You may try to test the connection using the command line interface 'psql'. > > > On Tue, Aug 23, 2011 at 10:39 PM, SSozuer wrote: > > > Settings in postgresql.conf are ok. And also postgresql is running > > > without no problem. As i said, i can connect database with pgAdmin > > > with no error. > > > Selcuk > > > > On Aug 23, 8:03 pm, Landy Chapman wrote: > > > > Also did the the server actually start? On debian, > > > > /etc/init.d/postgresql start > > > > > > > > Try connecting on the local system. I would guess you can't. It > > > looks > > > > > > > like you have a problem with the socket directory. Permissions? > > > > > > remember to edit postgresql.conf -- make sure to change > > > > > listen_addresses = '*' > > > > > port = 5432 > > > > -- > > > 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. > > > -- > > Thanks, > > Subhranath Chunder.www.subhranath.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Could not connect postgresql database
Also did the the server actually start? On debian, /etc/init.d/postgresql start > > > Try connecting on the local system. I would guess you can't. It looks > > > like you have a problem with the socket directory. Permissions? > > remember to edit postgresql.conf -- make sure to change > listen_addresses = '*' > port = 5432 -- 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: Could not connect postgresql database
> > On Tue, Aug 23, 2011 at 2:05 PM, SSozuer wrote: > > > Is the server running locally and accepting > > > connections on Unix domain socket "/var/run/postgresql/.s.PGSQL. > > > 5432"? > > > Try connecting on the local system. I would guess you can't. It looks > > like you have a problem with the socket directory. Permissions? remember to edit postgresql.conf -- make sure to change listen_addresses = '*' port = 5432 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Development environment
-debian (squeeze) with a few KDE "testing" packages -jEdit with plugins: "Buffer List", "Editor Scheme", "Text Autocomplete" -Eterm, nano,git, qgit -postgresql, sqlite, nginx, apache2 I'd love to hear from people using Windows XP/VISTA/7, and Mac OS X -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Not Populating AutoField
On Aug 19, 2:05 pm, Lee wrote: > Landy - thanks for that idea. Am I correct in understanding that > setting a field to AutoField has no effect on save_model, and simply > causes dbsync to add the sequence/nextval to the Postgres table? I am not sure; On a droid phone so I can't look at the source code or run tests. > If so > that is my problem, because I want to have one database schema that > works across different DBMSes, and the sequence/nextval syntax is > Postgres-specific so I have not been using dbsync. Django abstracts this away.. If django is creating your tables, you can trust it will do The Right Thing(tm) for whatever DBMS you are using. If you're not the trusting type you can run this command to find out what django would do to create your tables: django-admin.py sqlall Then you can change the database_backend in settings.py to find out what the differences would be. > I was hoping AutoField caused the *application* to manage the auto- > incrementing primary key, not the database -- is there an easy way to > do this in Django/Admin? That is almost never a good idea (*maybe* there is an edge case I've never seen). It isn't easy to prevent collisions (two records with same id). Imagine two users adding new records at the same time. Why do that when the problem is already solved by your DBMS? > Thanks very much for the help. You're quite welcome! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Not Populating AutoField
Did you create the table using django? Can you post the table definition in postgresql? If you still have an empty database, you could try dropping the id column and do a django dbsync otherwise you may have to create a sequence and apply it to the id field. Something along the lines of: create sequence id_seq start 1 increment 1; alter table xxx alter column id set default nextval('id_seq'); -- 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: Getting ForeignKey not to CASCADE, SET NULL not working (postgresql)
Have a look: - http://old.nabble.com/Should-postgresql-cascade-after-truncate-td31886534.html - https://code.djangoproject.com/ticket/11665 http://groups.google.com/group/django-developers/browse_thread/thread/27fe52b8bd0ca105/49d5058a1594a428 -- 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: httpresponse creates file in /tmp
The example here: https://docs.djangoproject.com/en/1.3/howto/outputting-pdf/ does not use a file; it uses the a file-like object: HttpResponse. That is how my code does it. When I get back I will check if my pdf report also creates a file in /tmp -- 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: Template html works when double clicked but empty when accessed through server
Jani Tiainen is right > > You can't (and you shouldn't) use file urls in your original source but > > should let the Django handle urls to them for you. ..or hard-code relative links in your templates. I was thinking about the file:/// un your urls; not the best idea but they are absolute and will work on your local machine. We know your template is rendering because > Yes the title changes but my table does not appear. It only appear if i > double click it ... :( Were you using firefox before? If yes, that security error should have nothing to do with it. My reasoning is some, if not all of your file:/// urls are being used by FF -- since the double-click event is being handled, and then the table appears. -- 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: Template html works when double clicked but empty when accessed through server
>From what I can tell it's not your fault. have a look at: http://code.google.com/p/slickgrid/issues/detail?id=19 fix might be here http://drupal.org/node/1094054#comment-4825024 -- 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: Template html works when double clicked but empty when accessed through server
When you get a blank page Does the title change? Is debug mode on/off? Is there an error message? You could add this: My html IS being displayed -- 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: Template html works when double clicked but empty when accessed through server
On Aug 15, 9:11 pm, Konstantin Sushenko wrote: > what is the source code for the blank page? > beat me to the punch... can you paste the url you're using when you get a blank page urls.py views.py 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: For loop problem in template..Is this correct
You may be right. I am out of my element (pardon the pun). However, assuming your "content" was this: content = [ { 'roll_no':1, 'cell_no': 1, 'nationality':'nation1'}, { 'roll_no':2, 'cell_no': 2, 'nationality':'nation2'}, { 'roll_no':3, 'cell_no': 3, 'nationality':'nation3'}, the django template renderer will turn this (note quotes around nationality and email): > > $(function() { > i = 0; > > var data = []; > > {% for x in content %} > > data[i] = > > { > > roll_no: {{x.roll_no}}, > > cell_no: {{x.cell_no}}, > > nationality: '{{x.nationality}}', > > e_mail: '{{x.e_mail}}' > > }; > i +=1; > > {% endfor %} into this: $(function() { i = 0; var data = []; data[i] = { roll_no: 1, cell_no: 1, nationality: 'nation 1', e_mail: 'email1' }; i +=1; data[i] = { roll_no: 2, cell_no: 2, nationality: 'nation2', e_mail: 'email2' }; i +=1; data[i] = { roll_no: 3, cell_no: 3, nationality: 'nation3', e_mail: 'email3' }; i +=1; My JS guy has left for the day... maybe someone else can help out. Also the 'autoescaping' should be on, in case some nationality contains a (') Ex: "G'ermany" HTH -- 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: For loop problem in template..Is this correct
@Konstantin Sushenko nice catch! >> as a result of this you will have a series of 'data[i] = ...' >>assignments in your output. where 'i' would be undefined. So could he use this: JS isn't my thing, and this is approaching too_clever > $(function() { i = 0; > var data = []; > {% for x in content %} > data[i] = > { > roll_no: {{x.roll_no}}, > cell_no: {{x.cell_no}}, > nationality:{{x.nationality}}, > e_mail:{{x.e_mail}} > }; i +=1; > {% endfor %} > grid = new Slick.Grid("#myGrid", data, columns, options); > $("#myGrid").show(); > }) > > and the error i get is > > Exception Type: TemplateSyntaxError > Exception Value: Could not parse the remainder: '(len(content))' from > 'range(len(content))' > > Template error > > In template d:\django-1.3\django\bin\onlinedemo\dbdemo\templates\db.html, > error at line 34 > Could not parse the remainder: '(len(content))' from 'range(len(content))' > > -- > > On Tue, Aug 16, 2011 at 4:50 AM, Konstantin Sushenko wrote: > > > > > > > > > hello, > > > as a result of this you will have a series of 'data[i] = ...' > > assignments in your output. where 'i' would be undefined. > > > konstantin > > > On Aug 15, 7:45 pm, Adam Zedan wrote: > > > Hi i am getting a problem with my for loop which i used in my > > template.Could > > > you kindly let me know what is going wrong in here. > > > The for loop is in a jquery function > > > > $(function() { > > > var data = []; > > > > {% for x in range(len(content)) %} > > > data[i] = > > > { > > > roll_no: {{content[x].roll_no}}, > > > cell_no: {{content[x].cell_no}}, > > > nationality:{{content[x].nationality}}, > > > e_mail:{{content[x].e_mail}} > > > > }; > > > {% endfor %} > > > > grid = new Slick.Grid("#myGrid", data, columns, options); > > > > $("#myGrid").show(); > > > }) > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: For loop problem in template..Is this correct
On Aug 15, 11:45 pm, Adam Zedan wrote: > Hi i am getting a problem with my for loop which i used in my template.Could > you kindly let me know what is going wrong in here. > The for loop is in a jquery function I think this: > {% for x in range(len(content)) %} .. is not allowed --no python in django templates. Do you have a sample (2 or 3 elements) showing how content is defined? If content came from a query, this should work: >{% for x in content %} > data[i] = > { > roll_no: {{x.roll_no}}, > cell_no: {{x.cell_no}}, > nationality:{{x.nationality}}, > e_mail:{{x.e_mail}} > }; > {% endfor %} -- 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: New user - Trouble starting
Hopefully this will help >> http://weblog.greenpeace.org/it/2006/04/getting_started_with_django_on.html > I'm trying to start the tutorial (on Windows by the way) and I can't > get anywhere. When I enter "django-admin.py startproject mysite" into > either the interpreter or the Python command line I get the same > message: > Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information.>>> import > django > >>> django-admin.py startproject mysite > > ^ > SyntaxError: invalid syntax that's fine; the django-admin.py "command" is run from the command line, not python shell. :-) > What am I doing wrong? -- 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: Convert dictionaries to django model (recursively)
This forum may help you with the dictionary-within-dictionary... >> http://www.daniweb.com/software-development/python/threads/248240 for help with your models, check out (at least) >> https://docs.djangoproject.com/en/1.3/intro/tutorial01/ >> https://docs.djangoproject.com/en/1.3/intro/tutorial02/ >> https://docs.djangoproject.com/en/1.3/ref/models/relations/ -- 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: using djblets data grid.. simple question
> I am trying to construct a simplest example to see the djblets data grid in > action > > def test(request): > countries = [ {'name': 'Australia', 'population': 21, 'tz': 'UTC +10', > 'visits': 1}, > {'name': 'Germany', 'population': 81, 'tz': 'UTC +1', > 'visits': 2}, > {'name': 'Mexico', 'population': 107, 'tz': 'UTC -6', > 'visits': 0},] > > //How can i incorporate the dictionary object to the datagrid?? You're making a list of dictionaries ...which is not the same as a Model object that djiblets datagrid wants. > How can i display the contents of dictionary in the djblets datagrid ?? > > My question is how can i display the dictionary object in the dblets > datagrid?? I would say make a model, create a queryset object and pass it to djiblets. Disclaimer: I didn't dig in djiblets beyond getting it to work with models; it still may be possible to do what you want. -- 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: Json serialization help
> The response is something like: > 'Content-Type: text/html; charset=utf-8\n\n[{"pk": 1, "model": > "MyApp.foo", "fields": {"choice_field": "db_name1"}}]' This is interesting.. But I think the serializer is working properly. the first element in the tuple is the value stored in the database, and second is the human readable version (might be used in a dropdown/ combo box). > I would like to get something like: > 'Content-Type: text/html; charset=utf-8\n\n[{"pk": 1, "model": > "MyApp.foo", "fields": {"choice_field": "Display Name 1"}}]' This (inelegant) solution may work: # change max_length on model to the longest 'display name SAMPLE_CHOICES = (_('Display Name 1'), _('Display Name 1')), (_('Display Name 2'), _('Display Name 2')) ) -- 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: Weird Problem: Template Shows Templatevariable's Name Instead Of It's Value
Hi, your template is missing a closing double-quote this line > "month{% endif %} > should be > "month"{% endif %} > Also by reformatting a little I noticed you close a with a {% for current, entry, month, n in months %} {% if entry %}{% endif %} http://foo.bar/";>{{ month }} {% if entry %}{% endif %} {% if n == 6 %}{% endif %} {# show content of the variables for debugging #} cur: {{ current }} entr: {{ entry }} mon: {{ month }} n: {{ n }} {% endfor %} -- 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: Connecting to the django app from outside the server
> The builtin dev server is not meant to be {{USED IN production}}, Python_junkie is NOT in production. > and setting up apache+mod_wsgi (DaemonProcess mode) is no big deal. It can be for beginners; it can wait until app will be deployed >> I am presuming that I can continue to use the django light weight web >> server for demonstration purposes. You will need to run the devserver, then you can access it from any browser. 'Remoting in' will also make it easier to "bounce" [stop, fix, restart] the server if you hit a critical error during your demonstration. -- 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: Connecting to the django app from outside the server
>The application runs when I remote into the server and run > the web pages with localhost on the 8000 port. > How do I connect to this web page for demonstration purposes when I am > not remoting into the virtual server. > > I tried just replacing localhost with the IP address with port 8000 > and that does not work. What command do you use to start the server? If your IP was 33.215.11.2 it would look like: python manage.py runserver 33.215.11.2:8000 > Do I need to open up port 8000 ? Yes Or figure out what port is already open and use that... Also check firewall status. > Is it possibly a permissions issue. Most likely not. > I am presuming that I can continue to use the django light weight web > server for demonstration purposes. Yes -- 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: Use object (User and custom object) in a form
copy/paste typo, sorry. It should have read/been: def formView(request, which_form=None): if request.method == 'POST': if not [1, 2].__contains__(which_form): pass # <--- iNone or nvalid form specified else: if which_form==1: form = form1(request.POST) redirect_url='/thanksForm1/'#was typo if which_form==2: form = form2(request.POST) redirect_url='/thanksForm2/' -- 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: Use object (User and custom object) in a form
I apologize since I tried to reply via gmail. Reposting & expanding part of a solution . > I've figured a way that I think will work best for me for the model > and form but I'm having trouble with writing the view. Here is my > pseudo code > > models.py > - > class baseModel(models.Model): >first_name = models.CharField( max_length=100, > verbose_name='first') > > class form1Model( baseModel): >pass > > class form2Model( baseModel): >pass > - The problem with the above definitions is that form2Model and form1Model would point to the *same* database table; that's what you do_not_want. [of course, no table is specified above.] You'd need, at a minimum, something like this: class BaseModel(models.Model): class Meta: abstract = True class Form1Model(BaseModel): # Specify the table to use for Form1Model class Meta(BaseModel.Meta): db_table = 'table1' class Form2Model(BaseModel): # Specify the db table to use for Form2Model class Meta(BaseModel.Meta): db_table = 'table2' #<--- table in db specified here The following should then work for you (after db_sync): > forms.py > - > class baseForm(ModelForm): > > > class form1( baseForm ): >class Meta(baseForm.Meta): >model = models.Form1Model > > class form2( baseForm ): >class Meta(baseForm.Meta): >model = models.Form2Model > - > I'm not sure how to create a view that can be reused. The only > difference is the form name and the 'thank you' page. I thought about > a Decorators but it doesn't seem like that is the right tool to use. > > view.py > - > def form1View(request): > >if request.method == 'POST': >form = form1(request.POST) > >if form.is_valid(): >form.save() >return HttpResponseRedirect('/thanksForm1/') # ---># you're missing code for NOT (form.is_valid()) >else: >form = form1() >return render_to_response('form_template.html', {'form': form} ) > I'm guessing here that you want both forms to be processed with the same view function? If the forms are submitted from different pages there are a few ways to do this. --Pass a variable from urls.py and rewrite the view: def formView(request, which_form=None): if request.method == 'POST': if not [1, 2].__contains__(which_form): pass # <--- iNone or nvalid form specified else: if which_form==1: form = form1(request.POST) redirect_url='/thanksForm2/' if which_form==2: form = form2(request.POST) redirect_url='/thanksForm2/' if form.is_valid(): form.save() return HttpResponseRedirect(redirect_url) --Pass a variable from separate views: def Form1View(request): formView(request, which_form=1) def Form2View(request): formView(request, which_form=2) -- 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: same form model with separate admins and data
I apologize since I tried to reply via gmail. Reposting & expanding part of a solution . > I've figured a way that I think will work best for me for the model > and form but I'm having trouble with writing the view. Here is my > pseudo code > > models.py > - > class baseModel(models.Model): > first_name = models.CharField( max_length=100, > verbose_name='first') > > class form1Model( baseModel): > pass > > class form2Model( baseModel): > pass > - The problem with the above definitions is that form2Model and form1Model would point to the *same* database table; that's what you do_not_want. [of course, no table is specified above.] You'd need, at a minimum, something like this: class BaseModel(models.Model): class Meta: abstract = True class Form1Model(BaseModel): # Specify the table to use for Form1Model class Meta(BaseModel.Meta): db_table = 'table1' class Form2Model(BaseModel): # Specify the db table to use for Form2Model class Meta(BaseModel.Meta): db_table = 'table2' #<--- table in db specified here The following should then work for you (after db_sync): > forms.py > - > class baseForm(ModelForm): > > > class form1( baseForm ): > class Meta(baseForm.Meta): > model = models.Form1Model > > class form2( baseForm ): > class Meta(baseForm.Meta): > model = models.Form2Model > - > I'm not sure how to create a view that can be reused. The only > difference is the form name and the 'thank you' page. I thought about > a Decorators but it doesn't seem like that is the right tool to use. > > view.py > - > def form1View(request): > > if request.method == 'POST': > form = form1(request.POST) > > if form.is_valid(): > form.save() > return HttpResponseRedirect('/thanksForm1/') # ---># you're missing code for NOT (form.is_valid()) > else: > form = form1() > return render_to_response('form_template.html', {'form': form} ) > I'm guessing here that you want both forms to be processed with the same view function? If the forms are submitted from different pages there are a few ways to do this. 1. (sloppy) Pass a variable from urls.py this will also require rewriting the view: def formView(request, which_form=None): if request.method == 'POST': if not [1, 2].__contains__(which_form): pass # <--- iNone or nvalid form specified else: if which_form==1: form = form1(request.POST) redirect_url='/thanksForm2/' if which_form==2: form = form2(request.POST) redirect_url='/thanksForm2/' if form.is_valid(): form.save() return HttpResponseRedirect(redirect_url) def Form1View(request): formView(request, which_form=1) def Form2View(request): formView(request, which_form=2) -- 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: Use object (User and custom object) in a form
I think you have a *namespace* problem. > and finally my forms.py : > >from django import forms >from django.contrib.auth.models import User > > > Error was: 'module' object > > has no attribute 'User' #-- You are importing everything in "django/forms/" into your namespace as "forms.*", which comes from the installed files django/forms/ widgets.py fields.py forms.py models.py None of those define 'User' > my forms.py >class CommentForms (forms.Form): >cf_comment = forms.CharField() >cf_writer = forms.User() <- problem That line says "make a new object called cf_writer using the User class defined in the django forms module. -- 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: Use object (User and custom object) in a form
> class CommentForms (forms.Form): > cf_writer = forms.User() > > Error was: 'module' object > has no attribute 'User' > > Do you have any idea ? Normal forms don't include/automatically create 'User' as a field... The built-in comment app may be what you need: https://docs.djangoproject.com/en/1.3/ref/contrib/comments/models/#django.contrib.comments.models.Comment -- 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: MySQL data export to Excel sheet
This is not strictly a django question. What are the bounds (lower limit) for the library you are using eg is there really a row 0, col 0 in the spreadsheet? Give this a try #-- http://pastebin.com/jz6gH9yz -- 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: same form model with separate admins and data
> Also, would db sync work with this approach or would I have to > manually add the table? I'd recommend backing up your data (just in case you have a typo). db sync *should* create the new tables for you. I prefer to manually manipulate my database (I never used South.) -- 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: same form model with separate admins and data
Brian, have a look at: https://docs.djangoproject.com/en/1.3/topics/db/models/#abstract-base-classes > If I understand you correctly, your situation is: > > FORM 1 --> [table 1] > FORM 2 --> [table 2] > > where FORM1 and FORM2 are *identical*, > and TABLE1 and TABLE2 are *identical* (same structure) > > *identical* meaning definition is the same but names are different for > obvious reasons... >> You understand the problem correctly. I'm not sure how to implement >> your suggestion. Cool! Let's implememt your models first: # class MyBaseModel(models.Model): first_name = models.CharField( max_length=100, verbose_name='first') class Meta: abstract = True class myModel1(MyBaseModel): class Meta(MyBaseModel.Meta): db_table = 'table1' class myModel2(MyBaseModel): class Meta(MyBaseModel.Meta): db_table = 'table2' Now let's tackle your forms. > class abstractForm( ModelForm ): > class Meta: > model= myModel > > class myForm(abstractForm): > class Meta(myForm.Meta): > model.table_name = 'test_model' please review: https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#modelform I believe you're trying to avoid duplicate code (DRY==good!) but I think you'll be better served writing simpler form code. # class Form1(ModelForm): class Meta: model = MyModel1 class Form2(ModelForm): class Meta: model = MyModel2 Hope that helps! -- 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: same form model with separate admins and data
If I understand you correctly, your situation is: FORM 1 --> [table 1] FORM 2 --> [table 2] where FORM1 and FORM2 are *identical*, and TABLE1 and TABLE2 are *identical* (same structure) *identical* meaning definition is the same but names are different for obvious reasons... If I understand you correctly I can help you with this. In other words Bruno's suggestion above fits perfectly, and you just override the table_name parameters in the child classes. -- 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.