Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

nbv4 posted:

Actually an abstract model can't be used here because the only use they have is prototyping other models. You can't call managers or anything else on abstract models. But a "multi-table" inheritance seem to work OK so far...

edit: If I run "music = Music.objects.all()", it returns a list of Music objects. How can I tell if a Music object is representing a CD or a record? I realize you can do "music.record.rotation_speed", but how can I tell which one it is?

Instinct says isinstance(some_music_obj, some_model_class) would work. Not sure if it's ideal though.

Adbot
ADBOT LOVES YOU

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

nbv4 posted:

edit: If I run "music = Music.objects.all()", it returns a list of Music objects. How can I tell if a Music object is representing a CD or a record? I realize you can do "music.record.rotation_speed", but how can I tell which one it is?

You should be able to check if music.record is None, music.cd is None, etc.

pokeyman posted:

Instinct says isinstance(some_music_obj, some_model_class) would work. Not sure if it's ideal though.

Pretty sure this doesn't work, because the Python objects returned are instances of Music even if they represent a Record tuple in the database.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

pokeyman posted:

Instinct says isinstance(some_music_obj, some_model_class) would work. Not sure if it's ideal though.

I'm having the same problem right now. I can't do that within the parent model class because the children are declared later in the file :cry:. You also can't create a foreign key to the abstract models. :(

Janitor Prime fucked around with this message at 06:51 on Nov 24, 2008

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

MEAT TREAT posted:

I'm having the same problem right now. I can't do that within the parent model class because the children are declared later in the file :cry:.

Come again? If you need to check isinstance() in a method, that'll work no matter where in the file the child is declared. If you define subclass models, instances of the parent model should have an attribute named after the child that you can check.

If in doubt, open a shell and instantiate some model objects, then poke at their attributes to see what each one defines.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
How do I go about doing this then?
code:
class GameActor(models.Model):
	isMonster = models.BooleanField()
	currentHP = models.IntegerField()
	def __eq__(self, other):
		return self.id==other.id
		
	def __unicode__(self):
		#get name of the child

class GameCharacter(GameActor):
	character = models.ForeignKey(Character)	
	armor = models.ForeignKey(Armor, related_name="%(class)s_armor_related", null=True, blank=True)
	mainHand = models.ForeignKey(Weapon, related_name="%(class)s_mainHand_related", null=True, blank=True)
	offHand = models.ForeignKey(Item, related_name="%(class)s_offHand_related", null=True, blank=True)
	wieldingTwoHanded = models.BooleanField()
	
	def __unicode__(self):
		return u"%s" % (self.character)
	

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
In the shell I can do stuff like this:
code:
actor = GameActor.objects.all()[0]
GameCharacter.objects.all().filter(pk__exact = actor.pk)
Which is what I'm using in my views, but in the admin whenever I have to deal with a ForeignKey to the GameActor table I have to stare at the ugly "GameActor: Object". I'm trying to do something similar to my code in the GameActor class to print out the correct name, but of course it won't let me because GameCharacter and GameMonster are defined later in the file.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
This is ugly, but one of the downsides of an ORM is that you basically throw away many of the benefits from polymorphism. If anybody has a better way to do this, I'd be eager to see it.

code:
class GameActor(models.Model):
    def __unicode__(self):
        if self.gamecharacter is not None:
            return unicode(self.gamecharacter)
        if self.gamemonster is not None:
            return unicode(self.gamemonster)
        return "Don't know what the gently caress this is"

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Janin posted:

This is ugly, but one of the downsides of an ORM is that you basically throw away many of the benefits from polymorphism. If anybody has a better way to do this, I'd be eager to see it.

code:
class GameActor(models.Model):
    def __unicode__(self):
        if self.gamecharacter is not None:
            return unicode(self.gamecharacter)
        if self.gamemonster is not None:
            return unicode(self.gamemonster)
        return "Don't know what the gently caress this is"

Close but it gives me a "DoesNotExist: GameCharacter matching query does not exist." I tried it and it seems to work on the characters only. When I try to get the name of a monster, it give me that error. Which makes sense since that property self.gamecharacter doesn't exist.

I'm just glad there is a somewhat sane solution to all this.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
code:
from django.core.exceptions import *

	def __unicode__(self):
		try:
			if self.gamecharacter is not None: 
				return unicode(self.gamecharacter)
		except ObjectDoesNotExist:
			pass
		try:
			if self.gamemonster is not None: 
				return unicode(self.gamemonster)
		except ObjectDoesNotExist:
			pass
		return "Don't know what the gently caress this is"
This works now! :D

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
Odd, perhaps that was on an older version.

If you're going to catch the exceptions, there's no need to check for a non-None attribute.

No Safe Word
Feb 26, 2005

MEAT TREAT posted:

code:
from django.core.exceptions import *

	def __unicode__(self):
		try:
			if self.gamecharacter is not None: 
				return unicode(self.gamecharacter)
		except ObjectDoesNotExist:
			pass
		try:
			if self.gamemonster is not None: 
				return unicode(self.gamemonster)
		except ObjectDoesNotExist:
			pass
		return "Don't know what the gently caress this is"
This works now! :D

You could do:

code:
def __unicode__(self):
    return unicode(getattr(self, 'gamecharacter', getattr(self, 'gamemonster', 'No clue'))

king_kilr
May 25, 2007
To the gentleman who wanted to have a view that combined querysets of different types that had a few common fields, I wrote a blog post about it today, hope it's helpful, here

The Red Baron
Jan 10, 2005

My seemingly decently elegant django.contrib.comments signal-based reCAPTCHA implementation, which I posted a link to earlier in this thread, suddenly got some serious egg on its face when someone pointed out that the comment framework's signal handling only allows for returning a HTTP 40x error when a signal handler returns false rather than redisplaying the form with a message. As a result, people mistyping the captcha get some seriously crappy feedback (or lack thereof). For reference, here's the link.

Is there no way of handling this with the current framework without subclassing the comments form and implementing custom logic? I was hoping that wouldn't be necessary :(

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

The Red Baron posted:

My seemingly decently elegant django.contrib.comments signal-based reCAPTCHA implementation, which I posted a link to earlier in this thread, suddenly got some serious egg on its face when someone pointed out that the comment framework's signal handling only allows for returning a HTTP 40x error when a signal handler returns false rather than redisplaying the form with a message. As a result, people mistyping the captcha get some seriously crappy feedback (or lack thereof). For reference, here's the link.

Is there no way of handling this with the current framework without subclassing the comments form and implementing custom logic? I was hoping that wouldn't be necessary :(

You could monkeypatch CommentForm.__new__ to apply a decorator on the security_errors function to check for recaptcha errors.

deimos fucked around with this message at 18:16 on Dec 10, 2008

The Red Baron
Jan 10, 2005

deimos posted:

You could monkeypatch CommentForm.__new__ to apply a decorator on the security_errors function to check for recaptcha errors.

I've considered doing that, or monkeypatching comments.get_form(), but the problem is that I need to supply the the client's IP address to recaptcha, and doing that from a form object is tricky because as far as I know, form objects only have access to the request.POST data and not the request.META data. From the comments code I can't see any obvious ways of getting a hold of the request object from that context. Why can't django as a rule pass the request object in kwargs or something to functions that are obviously meant to be user-overridable? :argh:

edit: would it be considered a horrible hack to wrap post_comment and send it a copy of the request object with an IP field injected into the POST map? :v:

The Red Baron fucked around with this message at 19:44 on Dec 10, 2008

nbv4
Aug 21, 2002

by Duchess Gummybuns
I have a model that has about 80 boolean values. Whats the Right Way to group these fields together? For instance, 12 of those boolean values are column1_hide, column2_hide, etc, which correspond to which columns the user wants to hide somewhere on the site. I'm going to define a function on the model that returns an array of each column the user wants hidden. If the user has column5_hide and column6_hide set as true, I want that function to return ["column5", "column6"]. I want to be able to iterate through all the columns in the model, instead of doing something like:

code:
def make_column_hide_array(self):
    return_array = []
    if self.column1_hide:
        return_array.append("column1")

    if self.column2_hide:
        return_array.append("column2")

    [...]
which would violate DRY. Does any of this make sense?

No Safe Word
Feb 26, 2005

nbv4 posted:

I have a model that has about 80 boolean values. Whats the Right Way to group these fields together? For instance, 12 of those boolean values are column1_hide, column2_hide, etc, which correspond to which columns the user wants to hide somewhere on the site. I'm going to define a function on the model that returns an array of each column the user wants hidden. If the user has column5_hide and column6_hide set as true, I want that function to return ["column5", "column6"]. I want to be able to iterate through all the columns in the model, instead of doing something like:

code:
def make_column_hide_array(self):
    return_array = []
    if self.column1_hide:
        return_array.append("column1")

    if self.column2_hide:
        return_array.append("column2")

    [...]
which would violate DRY. Does any of this make sense?
Well first of all you probably shouldn't have a model with 80 boolean values, you should use a bitmask or some other way of storing all those booleans in one field that's not quite so cumbersome.

But if you just need some code to help do what you want with what you've got, this does the job:
code:
L = []
for i in range(1, 12):
    if getattr(self, 'column%d_hide' % i):
        L.append('column%d' % i)

nbv4
Aug 21, 2002

by Duchess Gummybuns

No Safe Word posted:

Well first of all you probably shouldn't have a model with 80 boolean values, you should use a bitmask or some other way of storing all those booleans in one field that's not quite so cumbersome.

But if you just need some code to help do what you want with what you've got, this does the job:
code:
L = []
for i in range(1, 12):
    if getattr(self, 'column%d_hide' % i):
        L.append('column%d' % i)

Doesn't that still violate DRY? If you wanted to add an extra column, you'd have to change that 12 to a 13.

No Safe Word
Feb 26, 2005

nbv4 posted:

Doesn't that still violate DRY? If you wanted to add an extra column, you'd have to change that 12 to a 13.

DRY means "Don't Repeat Yourself" so it doesn't violate DRY but it does violate the "don't put hardcoded constants in code" best practice. And yeah, data model changes requiring code changes isn't that wacky of an idea in the first place. If you're changing your data model, chances are it's going to require a redeployment of the code anyway.

If you want to get really hairy and ugly you can introspect the column names and do it that way but really the best option (in my opinion) is to not have a data model like that.

MetaKnyght
May 18, 2004
My name is Jeff, not to be confused with the legendary eBay meta-scammer MyNameIsJeff
After some unsuccessful Google-ing, I figured I would turn to the experts.
A friend and I are looking to develop a turn-based strategy web-game (just for fun and practice). I have been playing around with Django at work lately, and am wondering if it would make a good platform for this. I know how to make traditional sites with it; however, I am stumped with where to begin on this. I'm not sure how the handle the time-based (turns, ticks, whatever) updates to the game database, and where in the application I should handle the game logic. Do I need some kind of separate process or application? Any advice would be greatly appreciated. Thanks.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Funny you should ask since I just finished my first Django project which was a turn based game. It was for an OOP course where good design was more important than if it actually worked. It was a lot of fun learning python and django, thankfully we came up with a good design (I think) for it. Our project was for D&D and this is how we handled the turns. I've removed all the irrelevant parts from it.

First we defined a Turn model which did nothing other than store whose turn it was and what actions they had already taken. We then created an Encounter model which had all the characters and all the monsters in it. Finally we had an Initiative model which had 2 foreign keys and the actual initiative score, one FK was the character/monster and the other the encounter.

With that established we had a few methods in the Encounter model, one to start the combat and one to find the next highest initiative and set the turn to that combatant. The start combat method just created the initiatives for each combatant, and set the turn to the highest initiative. From here we created a view for the players where they could choose to finish their turn and a view for the DM to start the encounter.

In the templates we used polling and AJAX to inform the next player that it was his turn and he could proceed to take actions as normal. Obviously if someone tried to take an action out of turn the view wouldn't allow them.

That is the jist of how we made our game work, there are lots of things you could do to change it up, like setting up a timer that would automatically call the next turn if the player doesn't respond after a set amount of time.

ashgromnies
Jun 19, 2004
I am trying to make an application for recipes using Django. I am starting simple and going from the tutorial but not getting the results I want. In a less strict framework I'd be able to represent what I want to easily but I'm having trouble figuring out how to do it the Django way while keeping the database clean and easy to query to prevent performance issues.

For this example, let's say I have two different models.

Recipe, and Ingredient.

A recipe has a name and a set of ingredients and an amount and measurement corresponding to each ingredient. An ingredient has only a name.

Here's an example schema of what the database in my mind would look like in 3NF:

code:
create table drinks (id int(11) auto_increment, name varchar(255));
create table ingredients (id int(11) auto_increment, name varchar(255));
create table drinks_ingredients (drinks_id int(11) not null, ingredients_id int(11) not null, amount int(11) not null, unit varchar(12));
or similar. That allows me to create only one row per a specific ingredient in the ingredients table(e.g. salt) and then use any measurement of it in the drinks_ingredients table. That way you can easily search for recipes containing a specific ingredient.

I'm having trouble figuring out how to get Django to recreate this database structure. The tutorial example with the poll application is similar but I'm not happy with the database schema because you can't use the same choice in multiple polls. This means that if you had 50 yes/no polls, you'd have "Yes" and "No" replicated in the database 50 times which, frankly, sucks.

I think I need to use a ManyToManyField for this but I'm having trouble finagling it to be the way I want. Here's what I have right now but I can't figure out where to put the amount and unit for the ingredients:

code:
class Ingredient(models.Model):
   name        = models.CharField(max_length=255)
   amount      = models.IntegerField()
   unit           = models.CharField(max_length=12)

   def __unicode__(self):
       return self.name
   class Admin:
       pass

class Recipe(models.Model):
   name        = models.CharField(max_length=255)
   ingredients = models.ManyToManyField('Ingredient')

   def __unicode__(self):
       return self.name
   class Admin:
       pass
Any ideas would be greatly appreciated :)

No Safe Word
Feb 26, 2005

ashgromnies posted:

I am trying to make an application for recipes using Django. I am starting simple and going from the tutorial but not getting the results I want. In a less strict framework I'd be able to represent what I want to easily but I'm having trouble figuring out how to do it the Django way while keeping the database clean and easy to query to prevent performance issues.
For this I generally just make the bridge table my own model, so I'd do something like:

code:
class RecipeIngredient(models.Model):
    recipe = models.ForeignKey(Recipe)
    ingredient = models.ForeignKey(Ingredient)
    amount = models.IntegerField()
    unit = models.ForeignKey(Unit)  # I know you have this as something different
                                    # but you should think about making this a lookup table
Also, these days (in Django 1.0+) you can wire up your admin stuff outside the models.py file - http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-objects

edit: vvvv well hot drat, those Django guys are pretty smart vvvv

No Safe Word fucked around with this message at 22:31 on Dec 25, 2008

mwarkentin
Oct 26, 2004
ashgromnies, I think you're looking for this:

http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships

Gone Fission
Apr 7, 2007

We're here to make coffee metal. We're here to make everything metal.
I'm trying to make a checkers game using Django. My main goal here is to find a way to make a game grid, which I could then use for other games.

Here is my model code for the board. It's kind of an ugly mess, and it uses a big-rear end list literal to build the board. I'm pretty sure this is a horrible way to do it. It's not DRY or flexible at all, there's no way in hell I'm going to be able to save this to a database, and moving things around on this board is going to be a pain in the rear end.

How the hell do you implement something like a game board? Surely I'm not the first person to try this, but even looking through PyGame articles I haven't managed to find anything.

EDIT: Okay, so I came up with a sort of ultra-simple mini-DSL for building game grids, it's a lot shorter and less ugly than my last try:

chess/boards/functions.py
code:
def build_game_grid(grid_string, symbol_hash):
    grid = []
    for line in grid_string.splitlines():
        row = []
        for char in line:
            try:
                row.append(symbol_hash[char])
            except:
                pass
        grid.append(row)
    return grid
chess/boards/models.py
code:
from chess.boards.functions import build_game_grid
# ...
class Board(models.Model):
    def __init__(self):
        self.grid = build_game_grid("""
            _x_x_x_x
            x_x_x_x_
            _x_x_x_x
            ________
            ________
            o_o_o_o_
            _o_o_o_o
            o_o_o_o_
        """, {
            '_' : square(),
            'x' : top_piece(),
            'o' : bottom_piece(),
        })
# ...
So now Board() returns a list structure, populated with objects created by my square(), top_piece(), and bottom_piece() methods, which I iterate over in my template to create an html table with magical jQuery links/pieces that you can select and deselect.

I still don't like the fact that it's implemented as a list of lists. At least now it can be more easily changed if I come up with a better idea.

And yeah, the project is called 'chess'. I scaled down the complexity early on, and never renamed it.

Gone Fission fucked around with this message at 07:12 on Dec 27, 2008

No Safe Word
Feb 26, 2005

So Adrian and company are working on an updated Django Book, and the work-in-progress is online for everyone to see like last time, yay!

http://www.djangobook.com/en/2.0/

(Django Book 2.0 covers Django 1.0 :mmmhmm: )

king_kilr
May 25, 2007

No Safe Word posted:

So Adrian and company are working on an updated Django Book, and the work-in-progress is online for everyone to see like last time, yay!

http://www.djangobook.com/en/2.0/

(Django Book 2.0 covers Django 1.0 :mmmhmm: )

James Bennet also announced(officially) that he's working on a 2.0 of Practical Django Projects.

Also, for those who haven't been following 1.1, there is going to be a crapton of new, awesome, stuff, I've been helping out with some of it and it's going to be awesome

mwarkentin
Oct 26, 2004
What're the best additions in 1.1, in your opinion?

king_kilr
May 25, 2007
Well aggregation is really nice, I love the API on it. Model validation is going to be a huge boon for people who want it just because there wasn't an easy workaround for those that needed it before(you could always write raw SQL). Plus bulk-editing stuff on the changelist actually looks great and can be a huge help for what should be simple tasks(for example making a BooleanField editable from there and just using it to enable stuff en masse).

Of course I've been following all of these, coded 1 myself, and provided a bit of assistance on the others, so I might be biased :)

mwarkentin
Oct 26, 2004
Any idea if the read-only admin fields are going to make it in?

king_kilr
May 25, 2007

mwarkentin posted:

Any idea if the read-only admin fields are going to make it in?

Possible, it's already possible to do in your own code though: http://lazypython.blogspot.com/2008/12/building-read-only-field-in-django.html

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Is there any cool way to push notifications from a Django app to prospective clients? Constantly polling seems kind of silly, but I can't think of a more effective way to do it. Something like the D&D guy above, he just polled to see when it was the player's turn. That's fine, but is there some crazy way he could've pushed a notification out from the server for that?

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

pokeyman posted:

Is there any cool way to push notifications from a Django app to prospective clients? Constantly polling seems kind of silly, but I can't think of a more effective way to do it. Something like the D&D guy above, he just polled to see when it was the player's turn. That's fine, but is there some crazy way he could've pushed a notification out from the server for that?

What I discovered was that HTTP is a client oriented protocol, that means that the only way for a server to communicate with a client is by responding to a request that they make. Look into Comet. According to that page the most common way is to use AJAX with long polling.

king_kilr
May 25, 2007
FYI aggregates: http://code.djangoproject.com/changeset/9742

No Safe Word
Feb 26, 2005

Has anybody had any luck extending the django.contrib.auth User model in their apps? I've been following the instructions on this blog post, but now when I try to login to the admin interface it's failing.

(note: this is with Django 1.0.2 final)

If I fire up the manage.py shell, and I do:

code:
In [1]: from django.contrib.auth.models import User

In [2]: User.objects.get(id=1)
Out[2]: <User: myusername>
I get back the right user and everything. Even if I reset the password in the shell and then try to login to the app, I just get:

admin app error message posted:

Please enter a correct username and password. Note that both fields are case-sensitive.
(yes, I put them both in correctly, checked caps lock and all that)

So I did a bit of digging:
code:
In [34]: from common.auth_backends import CustomUserModelBackend

In [35]: be = CustomUserModelBackend()

In [36]: be.authenticate(username='myusername', password='********')
Out[36]: <User: myusername>

In [37]:
What gives? According to the django docs on writing your own auth backend, this is exactly what should happen, and should be all that is necessary to happen. But the admin interface still craps out - is it just the admin interface being dumb? I haven't yet tried writing anything that uses authentication outside of the app, but if I can't figure anything else out that's probably my next step, though I get the feeling that won't work either.

Happycataclysm
Jan 11, 2005

The Fun Machine Took A Shit and Died

No Safe Word posted:

Has anybody had any luck extending the django.contrib.auth User model in their apps? I've been following the instructions on this blog post, but now when I try to login to the admin interface it's failing.

How are you starting the server? 'runserver' retains your db, 'testserver' recreates everything.

king_kilr
May 25, 2007
For those who are interested EuroDjangoCon registration is now open here: http://euro.djangocon.org/ . I've submitted a talk proposal on some advanced forms techniques.

Crazak P
Apr 11, 2003

PUNISHER > SPIDERMAN
How do I get django to recognize packages for python?

I installed mechanize (http://wwwsearch.sourceforge.net/mechanize/) and django can't seem to import it.

Or can I just get around this completely by using something within django to scrape imdb pages?

edit: I installed mechanized by running the setup.py, but there were also alternate instructions to just copy files into the Lib/site-packages directory. I did that and it worked. I'm guessing the setup.py installed it somewhere where only python could find it. I guess I now have two copies of mechanized floating around. Could anyone explain what happened?

Crazak P fucked around with this message at 09:07 on Feb 14, 2009

bitprophet
Jul 22, 2004
Taco Defender

Crazak P posted:

How do I get django to recognize packages for python?

I installed mechanize (http://wwwsearch.sourceforge.net/mechanize/) and django can't seem to import it.

Or can I just get around this completely by using something within django to scrape imdb pages?

edit: I installed mechanized by running the setup.py, but there were also alternate instructions to just copy files into the Lib/site-packages directory. I did that and it worked. I'm guessing the setup.py installed it somewhere where only python could find it. I guess I now have two copies of mechanized floating around. Could anyone explain what happened?

Unless you're doing something really funky with your PythonPath when Django loads up, Django is just Python, and should always have full access to anything on your global PythonPath.

Given what you said about lib/site-packages, I'm guessing that you may have 2 Python versions set up? That, or some other aspect of the configuration is messed up; typically, a python setup.py install SHOULD put stuff into your site-packages directory, and site-packages should always be on your PythonPath (and it sounds like it is).

Long story short: tell us exactly what OS you're using, what exact version you're on, and if possible, what version(s) of Python you've got and how they were installed (e.g. via MacPorts, via apt-get, from source, whatever). That should help figure out what's going on.

Adbot
ADBOT LOVES YOU

MetaKnyght
May 18, 2004
My name is Jeff, not to be confused with the legendary eBay meta-scammer MyNameIsJeff
I've searched for information on this, but can't really seem to find anything useful. I think my Google-fu has gotten weak.

What is the best way to run something automatically every so often? I want to go through my database and update it every 15 minutes or so. Is there any way to do this from within the main Django application, or does it need to be a seperate process or cron job? And finally, what is the best method for locking the database while the update is running so anybody accessing the web interface isn't going to receive partially updated data? Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply