Re: Using datetime.time object in form field choices
I also just realised that it's common to use an integer as the first element of a choice pair. Maybe the only restriction is that the datatype you use in the choice pair match the model field you're eventually saving it back to? On Sep 13, 3:20 pm, josephi wrote: > Hello > > I have a model Booking with a TimeField start_time on it. I want to > ensure that times entered into this field are whole hours only. > > I've set up a ModelAdmin object to use this model in the admin > interface. On the ModelAdmin I've used a custom ModelForm where I > override the default field for start_time and use a ChoiceField with > choices set to something like this ((time(9), '9 am'), (time(10), '10 > am'), ...). > > This seems to work perfectly well, with the correct time values being > saved to the database. The only real reason I'm asking this question > is that I couldn't find any examples of anything other than a string > being used as the first element of a choice pair. In my case I've used > a datetime.time. Can anyone think of any way that this might cause > problems or stop working in a future version of django? Is it intended > that you can use arbitrary objects in choices, or is this only working > accidentally? > > 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.
Using datetime.time object in form field choices
Hello I have a model Booking with a TimeField start_time on it. I want to ensure that times entered into this field are whole hours only. I've set up a ModelAdmin object to use this model in the admin interface. On the ModelAdmin I've used a custom ModelForm where I override the default field for start_time and use a ChoiceField with choices set to something like this ((time(9), '9 am'), (time(10), '10 am'), ...). This seems to work perfectly well, with the correct time values being saved to the database. The only real reason I'm asking this question is that I couldn't find any examples of anything other than a string being used as the first element of a choice pair. In my case I've used a datetime.time. Can anyone think of any way that this might cause problems or stop working in a future version of django? Is it intended that you can use arbitrary objects in choices, or is this only working accidentally? 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.
Caching/Reload problem - cannot refresh model data
Greetings All, Now, you may think me a bit of an asshat for doing it this way, but I have a MySQL db backend, DJANGO admin, and a self-coded desktop application ('InsectApp') written in Python. The 2 apps, DJANGO-Admin & InsectApp, both use the same 'settings' file and access the same data (I coded InsectApp so it would use the DJANGO database API because I thought it would make life easier!). The problem: is that there are now 2 ways of entering data, one via either app. For example, I'm in InsectApp and have imported model 'species' (InsectApp.models.speices) - meanwhile I add a new 'species' record via the Admin. On returning to InsectApp, I cannot access the new record unless I exit and restart the app. I have tried reloading InsectApp.models but it doesn't work. I'm assuming it's something to do with caching the data on first import of model 'species', but I have no CACHES in my settings.py. In any case both apps use the same settings.py. Can anyone explain and/or help me? Is there even a way of doing it? Thanks in advance p.s. I need the Admin site because we need certain database info, eg species taxonomy, to be updated remotely by taxonomists. The InsectApp is for rapid entering of large amounts of data wihtin our local network, which would be too clunky using the Admin alone. Hence the 2 apps -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/eSnLEH5uZBkJ. 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.
Newbie problem installing Django
I get the below error msg when I try to install Django 1.3.1 on a windows7 64bit machine. Django-1.3.1/Django-1.3.1/docs/topics/install.txt says Installing an official release ~~ 1. Download the latest release from our `download page`_. 2. Untar the downloaded file (e.g. ``tar xzvf Django-NNN.tar.gz``, where ``NNN`` is the version number of the latest release). If you're using Windows, you can download the command-line tool bsdtar_ to do this, or you can use a GUI-based tool such as 7- zip_. [I used WinZip] 3. Change into the directory created in step 2 (e.g. ``cd Django- NNN``). 4. If you're using Linux, Mac OS X or some other flavor of Unix, enter the command ``sudo python setup.py install`` at the shell prompt. If you're using Windows, start up a command shell with administrator privileges and run the command ``setup.py install``. But when I typed "setup.py install" from the windows command line I got the following error msg. c:\Python27>cd Django-1.3.1 c:\Python27\Django-1.3.1>setup.py install Traceback (most recent call last): File "C:\Python27\Django-1.3.1\setup.py", line 69, in version = __import__('django').get_version() ImportError: No module named django c:\Python27\Django-1.3.1> What did I do wrong and what do I have to change. You can either respond to me on this list or by email direct to ewpor...@gmail.com Ed Porter -- 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: Alter the list of fields returned by a queryset without turning them into strings?
On Mon, Sep 12, 2011 at 8:41 PM, Joshua Russo wrote: > Do I just need to do a little more pre-processing in the view or can I > accomplish what I'm trying to do? The method you're looking for is ``only()`` (or perhaps its cousin, ``defer``): https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.only. ``only()`` takes a list of fields like ``values()``, and constrains the SELECT clause similarly, but instead of returning a dictionary returns a model instance, so things like the FileFile objects work correctly. Do note that if you use ``defer()``/``only()`` and the access a field *not* in the select list Django will go perform another query for you, thus making things less efficient. So only reach for ``only()`` when you know you're only accessing the specific named fields (as it looks like you are in your example). Good luck, Jacob -- 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.
Alter the list of fields returned by a queryset without turning them into strings?
I have 2 tables, document and event. I want to retrieve the document url and the event date but it seems like I can't do this in a single query set and that is then used directly in a template. This was my first thought: context = { 'minutes': Document.objects.filter(documentType=1, event__eventType=1).values('documentFile', 'event__start_date').order_by('event__start_date') } with the template looking like {% for scm in minutes %} ⋅ {{ scm.event__start_date|optTimeShort }} {% endfor %} The problem is that the values() command turns the FileField into a string. If I remove the values() command I can access the event through event_set but it's not clear to me how to access the one and only event in the set within the template. Do I just need to do a little more pre-processing in the view or can I accomplish what I'm trying to do? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/kFEzUs3fmigJ. 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 gedit for django development
This is awesome dude. I was looking for something like this since I moved to Ubuntu. On 13 September 2011 10:12, Micah Carrick wrote: > I've written a blog post on using gedit, the default text editor in GNOME, > as a Django IDE. If you're a Linux user and you've never considered using > gedit for development then this may be an interesting read for you. > > http://www.micahcarrick.com/gedit-as-a-django-ide-for-linux.html > > > -- > 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.
Using gedit for django development
I've written a blog post on using gedit, the default text editor in GNOME, as a Django IDE. If you're a Linux user and you've never considered using gedit for development then this may be an interesting read for you. http://www.micahcarrick.com/gedit-as-a-django-ide-for-linux.html -- 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: Class-based FormView Contact Form
Hi Russ, Thanks for the input. I am actually looking to use FormView as opposed to UpdateView or CreateView because I am not working with model data at all: I want to create a simple contact form, and send the data of the form to a recipient via email - I don't want to write anything to the db at all. I am pretty new to Django so maybe this is obvious to some. Anyway, the way I understand your answer it is basically to do with model data. I'll dig into the source code. thx -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/zSYRSHSDqF0J. 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.
Interactions among values, annotate, and aggregation in django querysets
I posted this in StackOverflow, and haven't gotten an answer there yet. I'm hoping someone here can answer my question. I don't know if this represents a django bug, or a lack of understanding on my part. Link: http://stackoverflow.com/questions/7276147/interactions-among-values-annotate-and-aggregation-in-django-querysets Copy of text: I have these two models: class Leaf(models.Model): pass class Root(models.Model): leafs = models.ManyToManyField(Leaf) species = models.CharField(max_length=20) age = models.FloatField() objects = CustomQuerySetManager() class QuerySet(query.QuerySet): def small(self): return self.annotate(leaf_count=models.Count('leafs')).\ filter(leaf_count__lt=6) def oldest_each_species(self): oldest_each_species = set() for d in self.values('species').annotate(models.Max('age')): some_oldest = self.filter( species=d['species'], age=d['age__max'] )[0] oldest_each_species.add(some_oldest) return oldest_each_species And this test harness: class AggTest(test.TestCase): def set_up(self): pass def test_surprise(self): for i in range(0,2): root = models.Root(species='oak', age=i) root.save() for j in range(0,4): leaf = models.Leaf() leaf.save() root.leafs.add(leaf) print "All Roots" for root in models.Root.objects.small(): print root.id, root.species, root.leafs.count() print "All oldest" for matron in models.Root.objects.oldest_each_species(): print matron.id, matron.age print "All small oldests DOESN'T WORK" for matron in models.Root.objects.small().oldest_each_species(): print matron.id, matron.age print "All small oldests again" for matron in models.Root.objects.\ filter(id__in=models.Root.objects.small()).\ oldest_each_species(): print matron.id, matron.age which prints: All Roots 1 oak 4 2 oak 4 All oldest 2 1.0 All small oldests DOESN'T WORK All small oldests again 2 1.0 I was surprised by the result, but the interactions between values(), annotate(), and aggregate() often surprise me. Unwrapping my query, I have Root.objects.annotate(leaf_count=models.Count('leafs')). filter(leaf_count__lt=6).values('species'). annotate(models.Max('age')) which turns into the SQL SELECT `autest_root`.`species`, MAX(`autest_root`.`age`) AS `age__max` FROM `autest_root` LEFT OUTER JOIN `autest_root_leafs` ON (`autest_root`.`id` = `autest_root_leafs`.`root_id`) GROUP BY `autest_root`.`species`, `autest_root`.`species` HAVING COUNT(`autest_root_leafs`.`leaf_id`) < 6 ORDER BY NULL As shown in the test [at "All small oldests again"], I have a work- around, adding a nested django query on the ids, so I'm not looking for a work-around, but better work-arounds are welcome. I would say I don't understand the interactions well enough to even know if this is a bug in django. If it is, I'll continue to use a work- around. If not a bug, I would like a better understanding of these interactions, and how to manage situations like this. My best guess would be to have small() return the nested query, to encapsulate the fact that it is using annotations to do its job. So: * Is this a bug in django? * Is there some documentation which explains what I'm seeing? * What is the "best practice" for dealing with this kind of 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: Trouble expressing a query in the ORM
On Sep 9, 8:28 am, Pewpewarrows wrote: > Tim Shaffer's response would have you doing N+1 queries, and having to loop > through all of your Target objects in-memory. Technically it would work, but > as soon as you have a decently sized amount of data in there it'd slow to a > crawl. > I just wanted to chime in and point out that select_related() is a helpful tool for avoiding n+1 queries in django. https://docs.djangoproject.com/en/1.3/ref/models/querysets/#select-related It may not be particularly suitable for this particular problem (due to the requirement of bringing back only the most recent property on each target) but I wanted to mention it for the archives since no one else had. --Stuart -- 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.
New application : django-ajaxmiddleware
Hi django folks, I just wrote a middleware to handle ajax request really easily : https://github.com/Fandekasp/django-ajaxmiddleware I need some beta testers to give me some feedback, raise some bugs if my tests don't cover enough, etc. Thanks for your help, hope you'll like and adopt it as well :) I'm also open to critics if there is room for improvement in my code ! Cheers, Adrien Lemaire -- 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: Problems trying to use ManyToMany field before saving in a ModelForm
My advice is to use custom model form and hide these M2M fields if you are creating a new object. You can overwrite the init method of the form to do this. On Mon, Sep 12, 2011 at 6:01 PM, Carlos Brum wrote: > Hello guys, > > I have a problem to deal with a field ManyToMany in Django. It is > the following: > > When I try to access a list of relations that is my ManyToMany field > I get an error > > "%ModelName% instance needs to have a primary key value before a many- > to-many relationship Can be used. " > > I need to perform validation "before storing the record in the > database". > As you can see in the "view" code below, I used "save" in the > "ModelForm" with "commit = False" > so would build the ManyToMany relationship in memory. > > This did not work. > > I've tried to find the solution on the internet but found nothing that > work. > > Surely someone has been there. > > Thanks to collaboration. > > ## > # Source > ## > Note: The Model "Group" is the native Django admin > > ## > # Model > ## > > class Application (models.Model): > > . . . > > groups = > models.ManyToManyField (Group related_name = 'application') > > . . . > > eh_valida def (self): > > validating = True > > # ## > # HAVE PROBLEMS HERE. The attribute "self.grupos" is not > filled. It should be a list. > # Error: %ModelForm% instance > # Needs to have a primary key value before the > # Many-to-many relationship Can be used. " > # ## > > meuConjuntoDeGrupos = set (self.grupos) > > # ## > . . . > > return validating > > ## > # ModelForm > ## > AplicacaoForm class (ModelForm): > > class Meta: > model = Application > > > # View > > def adiciona_aplicacao (request, idQuestionario): > > form = AplicacaoForm (request.POST) > > if request.method == 'POST': > > if form.is_valid (): > > form.save (commit = False) > > if form.instance.eh_valida (): > > form.save (commit = True) > HttpResponseRedirect return (reverse (manager)) > # > > . . . > > -- > 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. > > -- eng. Ilian Iliev Web Software Developer Mobile: +359 88 66 08 400 Website: http://ilian.i-n-i.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-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.
Problems trying to use ManyToMany field before saving in a ModelForm
Hello guys, I have a problem to deal with a field ManyToMany in Django. It is the following: When I try to access a list of relations that is my ManyToMany field I get an error "%ModelName% instance needs to have a primary key value before a many- to-many relationship Can be used. " I need to perform validation "before storing the record in the database". As you can see in the "view" code below, I used "save" in the "ModelForm" with "commit = False" so would build the ManyToMany relationship in memory. This did not work. I've tried to find the solution on the internet but found nothing that work. Surely someone has been there. Thanks to collaboration. ## # Source ## Note: The Model "Group" is the native Django admin ## # Model ## class Application (models.Model): . . . groups = models.ManyToManyField (Group related_name = 'application') . . . eh_valida def (self): validating = True # ## # HAVE PROBLEMS HERE. The attribute "self.grupos" is not filled. It should be a list. # Error: %ModelForm% instance # Needs to have a primary key value before the # Many-to-many relationship Can be used. " # ## meuConjuntoDeGrupos = set (self.grupos) # ## . . . return validating ## # ModelForm ## AplicacaoForm class (ModelForm): class Meta: model = Application # View def adiciona_aplicacao (request, idQuestionario): form = AplicacaoForm (request.POST) if request.method == 'POST': if form.is_valid (): form.save (commit = False) if form.instance.eh_valida (): form.save (commit = True) HttpResponseRedirect return (reverse (manager)) # . . . -- 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: Implementing a List of Foreign Keys in a Model
Thanks a lot for that tip. I actually read over the Generic Foreign Keys several times before I asked the question but it still left me pretty confused. Is there a place I can see a good, straight-forward example of how this works? The "tags" example they had just didn't do it for me. Plus, they didn't really show how to call it from a command line which would be important to me. On Sun, Sep 11, 2011 at 4:32 AM, Daniel Roseman wrote: > > On Sunday, 11 September 2011 00:18:28 UTC+1, Kurtis wrote: >> >> Hey Guys, >> >> I have a very simple stub of a project. I'm trying to do something >> that should be very simple but isn't as easy as I hoped. >> >> I have a UserProfile class. This object is basically just an extension >> of the standard User Class. Within my UserProfile class, I want to >> have a list of PublicProfile foreign keys. PublicProfile itself is an >> abstract class with multiple classes extending it. For example, a User >> can create an ArtistProfile, a BandProfile, etc... >> >> To give you a sense of what I'm trying to accomplish from a user's >> perspective: A user can sign up and create multiple Pages (represented >> as PublicProfile) for bands, artists, etc... >> >> > > Sounds like you want [generic relations]( > https://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/#generic-relations > ). > -- > DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/MbkMEt65QFcJ. > > 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.
many to many in many relations
Hallo This question probably deserves a RTFM answer, but I have spent a few hours that I didn't have and would really appreciate a kick in the right direction. The thing is that I need to get registrations from colleagues. They need each of them to give a value per municipality, per month, per company. So the result is a kind of multidimensional matrix. I will store this in a database with a new row for each colleague- municipality-month-company combination My collegues, the municipalities, the months, and companis all has their own classes/tables so the class storing the result looks like this: class Prognose(models.Model): collegue = models.ForeignKey(Collegues) municipality = models.ForeignKey(Municipalities) month = models.ForeignKey(Months) company = models.ForeignKey(Companies) volum_value = models.IntegerField() In php or asp I would have nested iterations a and created a matrix of text boxes and built the insert statement from that. But I have a strong feeling that this has a much simpler solution using the philosophy of Django. Can I define ManyToMany relations to many tables like in this case? What is the right terms for this issue? BTW, Django looks really great, the parts that I have understood so far :-) Thanks /Nicklas -- 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: Admin Site appending letter "s" to end of each model\table name
I did not realize that my email client had not grabbed new mail from today and this was 2 days old. Sorry for the reply ad nauseum. Casey On 09/12/2011 09:24 AM, Casey Greene wrote: http://www.the-dig.com/blog/post/customize-plural-name-django-admin/ Casey On 09/10/2011 05:40 PM, Gillwill wrote: Apparently the Django default is to append the letter "s" to the end of the model name for each listed under a given application on the Site Administration page. (It does this in the tutorial sample site as well - e.g. naming "poll" "polls", etc...) Is there any way to get rid of that? I would think there would be, but I've yet to find in the default admin templates or code where it is doing this. Any help appreciated. -Gil -- 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: Admin Site appending letter "s" to end of each model\table name
http://www.the-dig.com/blog/post/customize-plural-name-django-admin/ Casey On 09/10/2011 05:40 PM, Gillwill wrote: Apparently the Django default is to append the letter "s" to the end of the model name for each listed under a given application on the Site Administration page. (It does this in the tutorial sample site as well - e.g. naming "poll" "polls", etc...) Is there any way to get rid of that? I would think there would be, but I've yet to find in the default admin templates or code where it is doing this. Any help appreciated. -Gil -- 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: two independent Django sites, one user - share User objects
You could pick one site to be your canonical site, and add it as a second db to the first, and then use a custom authentication backend to auth against that site, then create a local user with the same password hash. On Monday, September 12, 2011 at 7:38 AM, Markus Gattol wrote: > Say I have n (e.g. three) independent Django sites and one user. Rather than > having n times a password/username I'd like to share this across all n sites. > Also a users profile [0] and so forth. Now assume I don't want to use OpenID, > how would I be able to have User objects in sync across n Django sites? Maybe > using ZeroMQ and have each Django site listen to some actions on other Django > sites and then replay whatever action takes place on all Django sites? > > > [0] > https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/8wLFTRFTbG4J. > To post to this group, send email to django-users@googlegroups.com > (mailto:django-users@googlegroups.com). > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > (mailto: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.
two independent Django sites, one user - share User objects
Say I have n (e.g. three) independent Django sites and one user. Rather than having n times a password/username I'd like to share this across all n sites. Also a users profile [0] and so forth. Now assume I don't want to use OpenID, how would I be able to have User objects in sync across n Django sites? Maybe using ZeroMQ and have each Django site listen to some actions on other Django sites and then replay whatever action takes place on all Django sites? [0] https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/8wLFTRFTbG4J. 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: Multitenant in Django
This is similar to something we have used for one of our clients, except we used multihost.py :) +1 for this approach On Sun, Sep 11, 2011 at 3:49 PM, Alessandro Pasotti wrote: > 2011/9/9 sjtirtha > >> But I cannot set the SITE_ID in the settings.py right? >> Because if one user set the SITE_ID = 1, then parallel another user >> can set the SITE_ID = 2. >> Because we only have one instance. >> > > > Right, but AFAIK if you don't use threads you shouldn't have any problem. > > We have been using the middleware hack with Django 1.2.6 from more than one > year. > > The midleware run first and set settings.SITE_ID according to the current > site, something like > > http://dpaste.com/612953/ > > Currently running nginx + uwsgi but we used mod_wsgi for the last couple of > months. > > -- > Alessandro Pasotti > w3: www.itopen.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-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.