Re: new at this -- need some guidance
On Sat, Sep 10, 2011 at 8:36 PM, Danny Gale wrote: > Daniel, thank you very much. That's extremely helpful. > > What I'm trying to define is that every song can be on one album, but each > album can (of course) have many songs. For that, would it be better to use > the ManyToMany from Album to song or FK from song to album? If a song can only belong to one album, you don't have a many-to-many relationship between songs and albums, you have a many-to-one relationship. In Django, you use ForeignKey to define this (on the Song model). Check out https://docs.djangoproject.com/en/dev/topics/db/models/#many-to-one-relationships if you're curious. Cheers, Martin Melin -- 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: Virtualized Django app image for dev replication?
On Thu, May 19, 2011 at 4:30 AM, ydjango wrote: > I am thinking of creating a virtualized image of my complete django > app with mysql so that I can clone/copy it on developers, qa and demo > laptops. That way I do not have to do greenfield install on each > developer computer which can take many hours. > > Any suggestions on what should I use - 1) vmware server, 2) vmware > desktop 3) Xenserver or any other . Any experiences? > > I have not used any of these VM technologies. > > Note: It is only for dev and testing use and it is not for production > use. So free products are preferred. This is the exact problem that Vagrant http://vagrantup.com/ is trying to solve. It uses VirtualBox, which is free. I've just gotten into it myself but so far it's really useful. HTH, Martin -- 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: Having trouble synchronizing the database, can someone help?
On Tue, Feb 15, 2011 at 8:06 AM, Chen Xu wrote: > Hi, everyone: > I have a question about Django models, > so I created a Model: > > class Person(models.Model): > name = models.CharField(max_length=60) > > and ran the follwing: > > python manage.py syncdb > > this successfully did what I want, but later on, I added a new field into > a model > > class Person(models.Model): > GENDER_CHOICES = ( > (u'M', u'Male'), > (u'F', u'Female'), > ) > name = models.CharField(max_length=60) > gender = models.CharField(max_length=2, choices=GENDER_CHOICES) > > and I tried to run: > python manage.py syncdb again to sync my database, but it does not do it: > > So I am wondering if it is because since Person model already exists, it > will just simply ignore checking if the field changes. > And what I should do to sync the database? You're correct, the syncdb command will not modify tables in your database. What you're looking for is called database migrations, and a lot of (most?) people using Django use something called South for that. Have a look at http://south.aeracode.org/docs/, the tutorial is great. Best regards, Martin Melin -- 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: login-required
On Mon, Feb 14, 2011 at 9:40 AM, Szabo, Patrick (LNG-VIE) wrote: > Hi, > > I've tried using the @login_required decorator to limit acces to a > certain view. > This worked fine. > Unfortunately in the template that you are redirected to if the login > was succesfull I don't have acces to any information like username oder > alike. > > How do I realize that ?! > I'm assuming your question is how you can access the logged-in user's information in subsequent views and templates. If I've misunderstood your question please let me know. You need to make sure that you have the Session and Authentication middlewares installed. Have a look at this link: http://docs.djangoproject.com/en/dev/topics/auth/#authentication-in-web-requests Best regards, Martin Melin > For the login template i used the example shown in the documentation. > > My template looks like this: > > {% extends "main/base_site.html" %} > {% block content %} > TEST > ... > {% firstof request.user.id %} > ... > {% endblock %} > > Kind regards > > . . . . . . . . . . . . . . . . . . . . . . . . . . > Patrick Szabo > XSLT-Entwickler > LexisNexis > Marxergasse 25, 1030 Wien > > mailto:patrick.sz...@lexisnexis.at > Tel.: +43 (1) 534 52 - 1573 > Fax: +43 (1) 534 52 - 146 -- 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: Really annoying problem, First App part 1 related
On Thu, Dec 9, 2010 at 7:03 PM, Joe wrote: > Ok, so when I do exactly as the tutorial says, I get hella errors. I > change directory to where I want to store my project which goes fine, > then: >>>> django-admin.py startproject mysite > SyntaxError: invalid syntax > > with 'startproject' highlighted. The django-admin.py file is in the > directory I changed to. django-admin.py is a program that should be run in your OS shell, not in a Python interpreter which it looks like you're trying to do here. Regards Martin Melin -- 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: newbie question: @login_required, can't get it to work
On Thu, Dec 9, 2010 at 8:04 AM, Charlietuna wrote: > Hi All, > > I'm a newbie. I would like to use the @login_required decorator, but I > don't want to redirect to the standard default accounts/login. I would > like to redirect to '/login/' > > The book says add the following to the end of the settings.py file.: > > import django.contrib.auth > django.contrib.auth.LOGIN_URL = '/login/' Not sure where you're getting this information from, but assuming you're using the latest Django: http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL i.e. you should be using settings.LOGIN_URL and not django.contrib.auth.LOGIN_URL since at least 1.0 Cheers, Martin Melin > > The server says: GET /accounts/login/?login/=/save/ HTTP/1.1 404 2273 > I assume that it is going the path: > > /account/login/login > > Any help would be appreciated! > > Thanks, > > Steve -- 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: Using the Django Admin to change a password.
On Sat, Nov 20, 2010 at 10:44 AM, James Hancock wrote: > I have a strange problem and don't really know where to start looking to fix > it. Can someone point me in the right direction to figure this one out. > > > In the Admin interface when I try to use the "change password form" on any > of my users it gives me a > > "Page not found (404) > Request Method: GET > Request URL: http://goeigo.org/admin/auth/user/21/password/ > user object with primary key u'21/password' does not exist. > You're seeing this error because you have DEBUG = True in your Django > settings file. Change that to False, and Django will display a standard 404 > page. > " > error.. > > I can change the passwords from the terminal and create users and stuff, but > the admin page doesn't seem to work. > > Any hints? I assume that the rest of the admin is working? What version of Django are you using? Have you done anything out of the ordinary in urls.py? The problem seems to be that there is no URL pattern for the password change form, which means the user edit URL pattern will match instead, or that the pattern for password change comes after a broader pattern. Regards, Martin Melin > > Cheers, > James Hancock > > P.S. I love django -- 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: Adding help text to Django admin
On Mon, Oct 4, 2010 at 10:46 AM, Sithembewena Lloyd Dube wrote: > Greetings folks, > > I need to add "help text" to a Django admin. Sort of like the text below > fields in the Django Redirects app. to provide a snippet of information > about each field. > > How can I achieve this? http://docs.djangoproject.com/en/dev/ref/models/fields/#help-text Regards, Martin Melin -- 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: newbie question
On Mon, Oct 4, 2010 at 8:25 AM, mark jason wrote: > hi > I am quite new to django ..I have written a web app that takes user > input and adds customer details to db. > I store customer name,email ,a datetime value for each customer. > > When the application starts ,I want a utility program to check the db > and if system datetime matches the datetime value stored for each > customer, an email is sent to the customer. > > My doubt is ,where and how should I put the db checking and email > sending event logic.Should it be when the webserver starts(at python > manage.py runserver) ?If so ,where do I put the call to > check_db(),send_email() etc > > I know it is a silly one,but please understand that I am a newcomer to > django and python..and programming in general > > thanks and hoping for guidance > mark I assume the functionality you're after is that a specific user should receive an email as close to the datetime in their profile as possible? In that case, you don't want to run this only at application start. Generally it is not recommended to do anything at start, because depending on your environment it can be kind of undefined when "application start" actually occurs. "python manage.py runserver" is the so-called development server, and you should not rely on using it in production (when the app is on a server, not your local computer) A common way to solve problems like the one you're describing is to have a standalone script that runs periodically, triggered by cron. For info on writing scripts that have access to your Django project's models etc., have a look at Google's results for "django crontab" or similar. Good luck! Best regards, Martin Melin -- 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: Replace Admin Site Foreign Key Field/Dropdown with Textbox?
On Sun, Aug 8, 2010 at 4:00 PM, sixpackistan wrote: > For foreign key fields in the Django Admin, the default display > element is a drop down list box containing all of the foreign key > items from the related model. I have an asset tracking instance where > this drop down box can contain hundreds of thousands of items and I am > looking to not have the admin load them all. Is there a way to > override the admin interface and have it use a text box instead of the > populated drop down? Yup, documented right here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields Cheers, Martin -- 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: 'python manage.py startproject survey' does not add 'survey' to INSTALLED _APPS.
On Thu, Jul 29, 2010 at 10:51 PM, to_see wrote: > I am still new to Django, and am typing my way through some tutorials > (not running demo code). I could not figure out why I was getting > incorrect results in an Admin demo, until I looked at the sample > code. > > When I did this: > > django-admin.py startproject marketr > cd marketr > python manage.py startapp survey > > I got a full set of default filed, but settings.py did not include > 'survey' at the end of the INSTALLED_APPS list, as the demos > indicate. I have made several attempts, and not once have I gotten my > app in the list. It's seems easy enough, so I would like to find out > what I'm doing wrong. > > I'm running Django 1.2.1 with Python 2.6.5 on Ubuntu 10.04. > Considering that so many files are generated, correctly as far as I > can tell, I do not see why this one piece is missing. Especially > since I read the FAQ and searched this forum, and looked at the list > of tickets and don't see anything that matches. I think it would be bad form for startapp to edit your settings file. As far as the tutorial goes, adding your newly created app to INSTALLED_APPS is covered right here: http://docs.djangoproject.com/en/dev/intro/tutorial01/#activating-models Cheers, Martin -- 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: μ must be μ
2010/7/12 Alessandro Ronchi : > I want django to return μ instead of the html enscaped form μ in my > views, because I need it to return a reportlab template wich doesn't handle > the escaped version. > I already have an unicode template and unicode output, so I only those > characters not to convert to their HTML version. Isn't this simply the matter of running it through the template tag "safe"? {{ your_output_string|safe }} should output the unicode data verbatim. > > Is it possible? > How? > > Thanks in advance, > -- > Alessandro Ronchi > http://www.soasi.com > > Hobby & Giochi > http://hobbygiochi.com > http://www.facebook.com/hobbygiochi > > -- > 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. > Best regards Martin Melin -- 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.