Re: How to remove an app and its tables
Margie, I believe this may cause issues if for some reason that there is a call to those tables and it still finds a reference to it. Remember to go and remove them from the admin register that should get rid of all references to them. Michael I've stopped using a particular app in my project. I've used South to remove its tables, but I still see those tables referenced by the auth, content_type, and django_project_version tables. Is this ok? Anyone know if it will cause me any problems down the line? Margie -- 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. -- 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: Making a m2m field required
Yo'av, As far as I know there isn't a way to make a ManyToManyField a required field. blank = false cannot be used in ManyToMany or FileField's. You will have to come up with some way to validate the field seperately. Michael --- On Sat, 11/6/10, Yo'av Moshe wrote: From: Yo'av Moshe Subject: Making a m2m field required To: "Django users" Date: Saturday, November 6, 2010, 4:43 PM Hey, I'm getting frustrated with this... Is there any way to make a Many-to-Many field required? So that an object must have *at least one* relation (i.e. Article must have at least one Tag)? I'm showing Tag as an Inline in Article's from in the admin panel, but I can't find how to force the user to enter at least one Tag. Is it possible? Thank you, Yo'av. -- 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. -- 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: Making a m2m field required
In case you don't know how the clean() method works. When ever a form class is executed the generic Clean data is executed first then in the form class if there are any methods with the clean_formfield naming convention it will execute those automatically. This is basically the only way to force a manytomany field to have a value, but it only works in a form. Hope this helps you in your endeavour to complete your program. Michael Add a clean() method to your ModelForm, and raise a forms.ValidationError if self.instance.whatever.all().count() == 0. 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. -- 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: Total in a django template
Hello, I am not sure if this is what you are looking for but you can use a forloop.counter (index to 1) or a forloop.counter0 (index at 0) from within the template {% for loop %} Michael Hi, In a django template I have a for loop that display (item, fine). I would like to compute the total fine value at the end of the for loop. Is it possible to compute the total in the template? How can I do 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=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-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: Multi-table Inheritance: How to add child to parent model?
Hello, I was just going through this posting and I noticed that you are using concrete inheritance in your calling of class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) class Restaurant(Place): place = models.OneToOneField(Place, parent_link=True, related_name='restaurant') serves_hot_dogs = models.BooleanField() serves_pizza = models.BooleanField() Try class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) class Meta: abstract = True class Restaurant(Place): place = models.OneToOneField(Place, parent_link=True, related_name='restaurant') serves_hot_dogs = models.BooleanField() serves_pizza = models.BooleanField() This is abstract inheritance and any model inheriting Place will get a copy of Place's fields onto the child object instead of getting another Table placed there. Michael --- On Sat, 11/6/10, ringemup wrote: From: ringemup Subject: Re: Multi-table Inheritance: How to add child to parent model? To: "Django users" Date: Saturday, November 6, 2010, 7:48 PM That documentation is for pre-1.0 versions of Django, when model inheritance wasn't available at all. Multi-table inheritance doesn't seem to work identically to plain one-to-one relations. On Nov 6, 3:47 pm, Derek wrote: > See:http://www.djangoproject.com/documentation/models/one_to_one/ > > On 6 November 2010 14:47, ringemup wrote: > > > I can't find that example in this documentation [1]. Is there other > > documentation that I'm not aware of? > > > [1] > >http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-in... > > > On Nov 6, 5:59 am, Derek wrote: > > > The example shown in the online documentation. > > > > On 5 November 2010 18:24, ringemup wrote: > > > > > **{} is sort of the inverse of **kwargs in a function signature -- > > > > it's a way to use a dictionary in place of keyword arguments, and > > > > should function identically. > > > > > Which "original example" are you referring to? > > > > > On Nov 5, 10:25 am, Derek wrote: > > > > > You mean "trying to add a Restaurant which is linked to an existing > > > > place" > > > > > > I am not familar with the syntax you are using for the **{} wrapper. > > > > > > The original example shows: > > > > > > r = Restaurant(place=p1, serves_hot_dogs=True, serves_pizza=False) > > > > > > and the attached note says: > > > > > > Pass the ID of the "parent" object as this object's ID. > > > > > > Are you sure that the place ID is, in fact, what is being > > transferred? > > > > > > On 5 November 2010 15:59, ringemup wrote: > > > > > > > I'm not trying to create a Restaurant without a name and address. > > I'm > > > > > > trying to turn an existing Place into a Restaurant. > > > > > > > On Nov 5, 9:42 am, derek wrote: > > > > > > > Its not clear exactly what you think the problem is. The system > > is > > > > > > > behaving correctly ito the way you have set it up. > > > > > > > > 1. You have specified that name and address are compulsory fields > > in > > > > > > > Place. > > > > > > > 2. You have specifed that Restaurant must be linked to Place > > (i.e. > > > > > > > Place must be created before Restaurant can be created) > > > > > > > > So why would you now want an entry in Restaurant that does _not_ > > have > > > > > > > a name and address? > > > > > > > > On Nov 4, 10:25 pm, ringemup wrote: > > > > > > > > > I have an existing model that I want to extend using > > multi-table > > > > > > > > inheritance. I need to create a child instance for each parent > > > > > > > > instance in the database, but I can't figure out how. I've > > scoured > > > > > > > > google and haven't come up with anything other than Ticket > > > > #7623[1]. > > > > > > > > Here are some of the things I've tried... > > > > > > > > > Let's adapt the Place / Restaurant example from the docs: > > > > > > > > > class Place(models.Model): > > > > > > > > name = models.CharField(max_length=50) > > > > > > > > address = models.CharField(max_length=80) > > > > > > > > > class Restaurant(Place): > > > > > > > > place = models.OneToOneField(Place, parent_link=True, > > > > > > > > related_name='restaurant') > > > > > > > > serves_hot_dogs = models.BooleanField() > > > > > > > > serves_pizza = models.BooleanField() > > > > > > > > > I want to do the following, in essence: > > > > > > > > > for place in Place.objects.all(): > > > > > > > > restaurant = Restaurant(**{ > > > > > > > > 'place': place, > > > > > > > > 'serves_hot_dogs': False, > > > > > > > > 'serves_pizza': True, > > > > > > > > }) > > > > > > > > restaurant.save() > > > > > > > > > Of course,
Re: Automatically assume "models." prefix in models.py
hello James, I suppose you could use from django.db.models import WhatEver This would definitly work but I don't know if it is the way you want to go. Sincerely, Michael --- On Sun, 11/14/10, James wrote: From: James Subject: Automatically assume "models." prefix in models.py To: django-users@googlegroups.com Date: Sunday, November 14, 2010, 2:20 AM Forgive a django newbie... Maybe I'm the laziest person in the world, but sometimes I get tired of typing "models.WhatEver" for every single model I have to write. Is there anyway a shortcut could be added that would 'assume' the 'models.' prefix when I am defining a model? e.g. instead of: class SomeModel(models.Model): something = models.SomeField(someoption=something) # some other things Could a shortcut be added so that I can write: class SomeModel(models.Model): something = SomeField(someoption=something) # some other things I realized that not everything I will write will have the "models." prefix, but I think _most_ of what I write in models.py will have it. So... I'm a being too lazy, or perhaps just stupid? Thanks, -james -- 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. -- 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: CMS for django
I too like django-cms, although it has not been updated in a while it is still a good CMS. Plus the fact the CMS was built exclusively for Django. If you are a news media I would suggest using Ellington CMS but this is a costly adventure and sure only be used when there is a substantial amount material. Sincerely, Michael Sprayberry --- On Sun, 11/14/10, Robbington wrote: From: Robbington Subject: Re: CMS for django To: "Django users" Date: Sunday, November 14, 2010, 7:05 PM Depends what you want to do friend, The admin interface is pretty extensible on its own, flatpages etc. but if you are looking for some ready built options Django CMS is worth a look http://www.django-cms.org/ -- 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. -- 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: loggin limits
While the state is stateless you can create a user list and then control the number of user allowed to be logged on a given time. Read through this. http://www.djangobook.com/en/beta/chapter12/ Your best bet is to create a count that keeps track of total active session and only allows another once one ends. Sincerely, Michael --- On Tue, 11/16/10, Alex s wrote: From: Alex s Subject: loggin limits To: django-users@googlegroups.com Date: Tuesday, November 16, 2010, 7:40 PM Hi, I am planning to limit the number of users logged online in my application. How can I do it? Thanks Alex -- 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. -- 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: INSTALLED_APPS doesn't check my projet dir
Also make sure that in you app folder and every folder for that matter has a __init__.py that way python will view it as a module. --- On Wed, 11/17/10, Shawn Milochik wrote: From: Shawn Milochik Subject: Re: INSTALLED_APPS doesn't check my projet dir To: django-users@googlegroups.com Date: Wednesday, November 17, 2010, 11:14 AM When you put an app into INSTALLED_APPS, it looks on your PYTHONPATH. If you make an app intended to be pluggable, your users should be installing your application with pip or something, and your app code will exist on the PYTHONPATH, not in a subfolder of their Django project. If you want to develop your app in a manner more like it will be used, then put your app outside of your Django project, and on your PYTHONPATH. That will allow (force) you to import it as another developer who plugged in your app would. 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. -- 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: problems with model inheritance if base class is not abstract
--- On Sat, 11/20/10, marco.ferrag...@gmail.com wrote: From: marco.ferrag...@gmail.com Subject: problems with model inheritance if base class is not abstract To: "Django users" Date: Saturday, November 20, 2010, 5:59 AM Hi all! I'm new to django and I'm experimenting with models but I have some trouble. I've minimized my problem to this code: class TestBase(models.Model): base = models.CharField(max_length=255) from django.contrib import admin class TestA(TestBase): testb = models.CharField(max_length=255) admin.site.register(TestA) class TestB(TestBase): testc = models.CharField(max_length=255) admin.site.register(TestB) Trying to add TestA instances from admin interface I have this error: Cannot assign "''": "TestA.testb" must be a "TestB" instance. why testb should be a TestB instance?? It's a simple field! If TestBase is declared as abstract using the internal Meta Class I no more have the error. Is this a bug or there is something that I don't understand? Thanks in advance :) I think your issue is in how you are registering is should look like admin.site.register(TestBase, TestA) admin.site.register(TestBase, TestB) -- 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 configure database?
have you done python manage.py syncdb? --- On Mon, 11/22/10, pa_ree wrote: From: pa_ree Subject: how to configure database? To: "Django users" Date: Monday, November 22, 2010, 3:32 PM hello, i'm new to django framework. i want to know how can i configure a single database to two applications. the problem is essentially, that i first created a database and an application in two subparts, and configured the database to the first part of application. Now i want to link the second part of my app into the same database. In settings.py in INSTALLED_APPS i have included both, still it doesnt seem to wrk. any solution? -- 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. -- 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: tutorial part 4: ImportError
Steph, those instructions are incorrect try from djanog.views.generic import list_view, list_detail Michael --- On Tue, 11/23/10, steph wrote: From: steph Subject: tutorial part 4: ImportError To: "Django users" Date: Tuesday, November 23, 2010, 11:06 AM Hi group, I'm new - just worked thgough the tutorial. In part 4 about the use of generic views I've got a problem - I can't import ListView and DetailView: >>> from django.views.generic import DetailView Traceback (most recent call last): File "", line 1, in ImportError: cannot import name DetailView >>> from django.views.generic import ListView Traceback (most recent call last): File "", line 1, in ImportError: cannot import name ListView I'm on the newest version of django: first tried with version 1.2.3, then I upgraded to 1.3 alpha - same problem. Any clues? thanks, stephan ps: other than that it's a great tutorial! -- 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. -- 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 configure database?
share a little bit of your code so that we know what you are seeing. Just saying that you aren't getting things in your admin does not provide enough information. --- On Tue, 11/23/10, Reeti Pal wrote: From: Reeti Pal Subject: Re: how to configure database? To: django-users@googlegroups.com Date: Tuesday, November 23, 2010, 11:09 AM i ve used syncdb for database creation, i think the problem is sumthing at the admin page not at the models level. -- reeti -- 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. -- 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: HELP NEEDED
I would definitely go Django for this project and maybe divide out the project and get some people to help you seeing as this is your first project. Not only do you have to take into account the look up the website, the models for employers and freelancers, but you are also going to need to take into acount a Link to get these emails sent to the freelancers and also the replys to the employers and assumming you don't want to be giving out personal information this requires some allisoning. Good luck to you on this project and if you want help get back to me. Michael Sprayberry --- On Tue, 11/23/10, Dipo Elegbede wrote: From: Dipo Elegbede Subject: HELP NEEDED To: django-users@googlegroups.com Date: Tuesday, November 23, 2010, 1:26 PM Hi, I have done some extensive reading on python. i want to design a classifieds site for jobs. The service is meant to send people who register an sms with available jobs that fit their criteria/cv. But the main idea is that people come and register for quick jobs(like www.freelancer.com) and put up their criteria,age,location,qualificationsand when a company or employer posts a job,the people that fall into the category that was specified get sms and email alerts as to the availability of the job. I am taking this as my first project and would appreciate any help. I am looking in the direction of python, maybe django. Thanks. -- Elegbede Muhammed Oladipupo OCA +2348077682428 +2347042171716 www.dudupay.com Mobile Banking Solutions | Transaction Processing | Enterprise Application Development -- 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. -- 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: Django book
The Definite Guide to Django is good, but I liked Beginning Django E-Commerce that really nailed things down for me. --- On Sun, 11/28/10, Lorenzo Franceschini wrote: From: Lorenzo Franceschini Subject: Django book To: django-users@googlegroups.com Date: Sunday, November 28, 2010, 5:48 AM I'm new on this group, so first of all... Hi to everybody! I'm a web developer, and I need to approach Django for a software project, so I would like to ask you an advice about the best book to read (in your opinion) in order to learn using this framework, given that: * I already have some experience on web applications' development with PHP MVC frameworks like Drupal; * I have some experience of Python (non-web) programming; * I'd prefer printed books. Thanks in advance for any answer. -- 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. -- 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: populating model values into form
You will need to make an admin.py and follow these directions class FormAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("title",)} slug can be what ever field you want to populate and title is where you are populating from, as far as I know you can only populate from within the same area. then you need to register form and formadmin admin.site.register(form, formadmin) On Sat, Nov 27, 2010 at 8:11 AM, djangobeginner wrote: > Hi, > Im a beginner here, would just like to ask how to pass and populate > model values (from database) into a created form, I have the following > codes > > 1. I already have a webpage list of all the values in a table form > 2. If I click on any of the row with primary key id (example: clicking > edit link), it should redirect me to a created form (in forms.py) with > all the values populated based on the primary key id from the web > list. > > How do I possibly do #2? > Please help. thanks. > > given the following: > --- > models.py: > from django.db import models > import datetime > > SHORT_DATE_FORMAT = "%d - %b - %y" > DATE_FORMAT= "%Y-%m-%d" > TIME_FORMAT= "%H:%M" > > class Job(models.Model): >job_id = models.AutoField(primary_key=True) >job_title = models.CharField(max_length=50, verbose_name = > "Title") >job_desc = models.CharField(max_length=500, verbose_name = > "Description") >active_datetime_fr = models.DateTimeField('time') >active_datetime_to = models.DateTimeField('time') > - > views.py > def object_list(request, model): > obj_list = model.objects.all() > template_name = '/job_list.html' > t = loader.get_template(template_name) > c = RequestContext(request, {"object_list": obj_list}) > return HttpResponse(t.render(c)) > - > forms.py: > from django import forms > from django.db.models.fields import AutoField > from datetime import date, datetime > import psycopg2 > > class JobAddForm(forms.Form): >#job_id = forms.IntegerField() >job_title = forms.CharField(label='Title', initial='', > required=True) >job_desc = forms.CharField(label='Description', initial='', > required=False) >date_fr = forms.DateField(required=True, label ="Active From > Date") >date_to = forms.DateField(required=True, label ="Active To Date") >time_to = forms.TimeField(required=True, label ="Active From > Time") >time_fr = forms.TimeField(required=True, label ="Active To Time") > - > > -- > 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. > > -- 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.