Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How can I prevent post_save recursion in Django?
I have some problems when using signal in Django. post_save occurs recursion because of instance.save() inside of function. But strange thing is only one case occurs recursion. Case not occuring recursion. models.py class Product(TimeStampedModel): name = models.CharField(max_length=120) slug = models.SlugField(null=True, blank=True) description = models.CharField(max_length=400, blank=True) is_active = models.BooleanField(default=True) objects = ProductManager() class Meta: ordering = ('-created',) def __str__(self): return self.name def get_absolute_url(self): return reverse( "products:product_detail", kwargs={ "slug": self.slug, } ) signals.py @receiver(post_save, sender=Product) def post_save_product(sender, instance, created, **kwargs): if not instance.slug: instance.slug = slugify(instance.name, allow_unicode=True) instance.save() When I create Product using Product.objects.create() it doesn't occur recursion. Case occuring recursion models.py class Variation(TimeStampedModel): COLOR_CHOICES = ( ('black', '흑백'), ('single', '단색'), ('multi', '컬러'), ) price = models.DecimalField( decimal_places=2, max_digits=15, blank=True, null=True, ) product = models.ForeignKey(Product) color = models.CharField( max_length=10, choices=COLOR_CHOICES, default='흑백' ) is_active = models.BooleanField(default=True) class Meta: ordering = ('product',) def __str__(self): return "{product} - {color}".format( product=self.product, color=self.color ) signals.py @receiver(post_save, sender=Variation) def post_save_variation(sender, instance, created, **kwargs): if not instance.price: if instance.color == '흑백': instance.price = 40000 elif instance.color == '단색': instance.price = 50000 elif instance.color == '컬러': instance.price = 60000 instance.save() This case occurs recursion errors: File "/Users/Chois/.pyenv/versions/spacegraphy/lib/python3.5/site-packages/django/db/models/base.py", line 708, in save force_update=force_update, update_fields=update_fields) File "/Users/Chois/.pyenv/versions/spacegraphy/lib/python3.5/site-packages/django/db/models/base.py", line 745, in save_base update_fields=update_fields, … -
Django merge two migrations with the same ID?
I had an old git branch which has a migration that was never merged into our main branch. Since I made that migration, 14 or so migrations have been made. I have since rebased my old branch into our current branch and have two migrations: 0044_auto_20160810_1128 0044_auto_20160823_1613 I've tried running python manage.py migrate --merge- this just returns the following text: usage: manage.py migrate [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--noinput] [--no-initial-data] [--database DATABASE] [--fake] [--fake-initial] [--list] [app_label] [migration_name] manage.py migrate: error: unrecognized arguments: --merge I found this command from the following stack question: Django South migration conflict while working in a team All I'm trying todo is merge the two 0044 migrations so when I push to production it won't error. -
following the celery tutorial and I get this error No module named 'src'
I am following the celery tutorial and I get this error No module named 'src'. I dont understand what the issue is. this is my directory structure venv/ src/ __init__.py celery.py manage.py tasks.py my celery.py from __future__ import absolute_import from .gettingstarted.settings.local import BROKER_URL from celery import Celery app = Celery('src', broker=BROKER_URL, backend=BROKER_URL, include=['src.tasks']) # Optional configuration, see the application user guide. app.conf.update( CELERY_TASK_RESULT_EXPIRES=3600, ) if __name__ == '__main__': app.start() my tasks.py file from __future__ import absolute_import from proj.celery import app @app.task def add(x, y): return x + y @app.task def mul(x, y): return x * y @app.task def xsum(numbers): return sum(numbers) I also tried from __future__ import absolute_import import sys sys.path.insert(0, "/project/src/") from proj.celery import app that didnt work either. when I go into src directory and run python shell Iget the follwoing error No module named 'src' what's my malfunction? -
django- 404 message but no runserver error
Hi im trying to learn Django (doing the first parts of the turtorial >>docs.djangoproject.com/en/1.10/intro/tutorial02/) Im having a hard time getting my server to run, in a way that i can veiw and edit it on a website-like interface This is what is supposed to come up when I go on http://127.0.0.1:8000 Instead I get a 404 error message. this is what happens when I run Python manage.py runserver there arent really any Errors it just says the port is already in use, I think thats because I ran that line of code twice. Im not entirely sure exactly what files ill need to change to fix this my init.py seems to be empty(maybe thats the problem? idk doesnt seem like it) -
Timing, channels and transactions in django-channels
I think its possible in Channels for a channel to be completed at the wrong time, and I'm not sure how to resolve it. In my use case, I'm trying to run a search index updater via channels on save of an item. Synchronously it works like so: A1. item saved -> post_save signal thrown A2. post_save caught by function that sets a channel A3. channels processes messages and triggers a search index updater A4. updater queries database for updated object and updates index However, if the item being saved is wrapped in a transaction it can happen like so: B1. Transaction opened A1. item saved -> post_save signal thrown A2. post_save caught by function that sets a channel A3. channels processes messages and triggers a search index updater A4. updater queries database for and see the *old object* and updates index B2. Tranasction closed B3. new object hits the database I'm not sure how to get around this, but it came up when trying to run channels code in a test suite where all tests (and thus all object changes) are wrapped in transactions which meant that no changes were being picked up by the workers as they couldn't … -
Django/Mezzanine Display Menu in App for Specific Page/Slug with page_menu
In a Django/Mezzanine site I have an app which generates a list of information. Call this list of auto-generated data "Sock Deals," "Shoe Deals," "Sandal Deals" etc. Importantly, this information is shown as a displayable page but does not have a Django/Mezzanine model that inherits from the Page or RichTextPage classes. I have one RichTextPage called "Deals Summary" which is manually maintained but has some links in it to slugs which navigates to "Sock Deals" or "Shoe Deals" via code in views.py. The "Deals Summary" page has a nice left-menu populated with related Pages like "All Products" and "About Company" due to it being a RichTextPage managed by Mezzanine. This menu is generated in the template for "Deals Summary" via a call to the template tag page_menu. Unfortunately each the linked "Shoe Deals" "Sandal Deals" etc. have a weird looking left menu as they are not Mezzanine Pages and thus the system generates menu for stuff related to the app which creates this content rather than related pages. I would like the left-menu of related pages to for each of "Shoe Deals" "Sandal Deals" and so forth to be identical to the menu for the "Deals Summary" page rather than … -
Django: How to get latest value from db
So I want to get the latest result for a list of values from the database. Example: Task col1 col2 1 0 2 1 3 2 4 3 5 4 1 5 2 6 3 7 2 8 1 9 -> last occurence for '1' in 'col1' 4 10 -> last occurence for '4' in 'col1' 3 11 5 12 -> last occurence for '5' in 'col1' There's a list 'z' and I want to write query such a way that I get the latest results from the table 'Task' such that z exists in col1. Assuming 'z' is: z = [1, 4, 5] I want the end result as: col1 col2 1 9 4 10 5 12 There are 2 solutions that I came up with. Solution1 is as follows: all_results = Task.objects.filter(col1__in=z) results = dict() for result in results: results[result.col1] = result Solution2 is as follows: results = dict() for x in z: results[x] = Task.objects.filter(col1=z).reverse()[0] But I'm wondering if there's a way to combine both solutions together such that I only have to make one database call and get results for each distinct 'col1'. Reason: My database is very big and currently I've implemented Solution2 which is … -
'WSGIRequest' object has no attribute 'session' while upgrading from django 1.3 to 1.9
Similar to this question 'WSGIRequest' object has no attribute 'session' But my MIDDLEWARE classes are in the correct order. INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.messages', 'django.contrib.staticfiles', 'membership', 'treebeard', 'haystack', 'reversion', ] MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] I am redirecting to login url(r'^$', RedirectView.as_view(url='login/')), url(r'^login/$', 'membership.views.loginView', name='login'), and then def loginView(request): a = request.session Throws the error -
django filter and update
I have a resource model wich indicates if a resource is available or not and running multiple celery workers in 2 servers to retrieve the next available resource each time, set to unavailable and assign to other task. for example: Class resourceA(model.Model): A = models.CharField(max_length=10) available = models.BooleanField(default=True) Everytime, I just want to pick the next available resource and assign to task. If I do resource = resourceA.objects.filter(available=True).first() if resource: resource.available=False resource.save() then there is a chance that other workers might pick up the same resource and try to update that resource. Django has select_for_update to lock the entries. However, I dont want to lock and update all the available resources. Please suggest if there is a way I can retrieve and update in one shot? thanks! -
Django Queryset: filtering by related item manager
I have model for pages that consist of a number of content blocks. class Page(models.Model): ... class Block(models.Model): page = models.ForeignKey(Page) ... The Block has a handful of other properties that determine whether it is considered to be "active" or not (a couple booleans and a datetime field). I have a manager for the Block model so that I can get a list of active Blocks Block.objects.active() Page.objects.first().block_set.active() I want to be able to write a queryset to return only Page objects that have active blocks. I would like to do this using the existing Block active manager, so that I am only defining what makes an "active" block once (DRY). IE something like: Page.objects.annotate(count=Count('block__active')).filter(count__gt=0) Obviously that does not work since active is not a property of Block. Is there a way I can use the existing Block manager to achieve this? -
How do I check if a function is called in a mock method?
AuthUser is a class which contains the delete method. I want to test if the mock delete method calls a function, given the arguments for the method. @mock.patch.object(AuthUser, 'delete') @mock.patch('oscadmin.common.oscp.deactivate_user') def test_delete(self, deactivate_user_mock, delete_mock): """Test the delete() method in AuthUser""" authUserObject = mock.Mock() authUserObject.oscp_id = 4 """If delete_from_oscp = True && oscp_id isset""" delete_mock(self, True, authUserObject, mock.Mock()) self.assertTrue(authUserObject.oscp_id) -
Unable to load data from json.gz file - Django
I dumped my data into a json.gz file because I had to delete my sqlite file and remigrate my Django migrations. I successfully dumped my data into a json.gz file, but when I try to load that data using python3.5 manage.py loaddata , I get this error. django.core.serializers.base.DeserializationError: Problem installing fixture '/Users/timothybaney/Django_Projects/porschepalooza/backups/backup-2016-9-13-21-8.json.gz': Expecting value: line 1 column 1 (char 0) Full Stack Trace Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/management/commands/loaddata.py", line 60, in handle self.loaddata(fixture_labels) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/management/commands/loaddata.py", line 100, in loaddata self.load_label(fixture_label) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/management/commands/loaddata.py", line 152, in load_label for obj in objects: File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/serializers/json.py", line 85, in Deserializer six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2]) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/Users/timothybaney/Library/Python/3.5/lib/python/site-packages/django/core/serializers/json.py", line 78, in Deserializer objects = json.loads(stream_or_string) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/__init__.py", line 319, in loads return _default_decoder.decode(s) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None django.core.serializers.base.DeserializationError: Problem installing fixture '/Users/timothybaney/Django_Projects/porschepalooza/backups/backup-2016-9-13-21-8.json.gz': Expecting value: line 1 column … -
Celery executing a group of tasks from another task
I have this periodic task that runs from a celery worker. Each minute, the periodic task selects a set of services which are marked as dirty in order to re-configure something. If services are found, a group of tasks is supposed to be dispatched in order to run in parallel and do the configs. The problem is that those tasks are not doing anything and I'm guessing my main (the periodic task) never waits for them to complete: @periodic_task(run_every=crontab(minute='*')) def refactor(): services = Service.objects.filter(is_dirty=True).all() tasks = [service_refactor.s(service_id=s.id) for s in services] result = group(tasks)() while not result.ready(): time.sleep(1) return result.successful() service_refactor is the second task being called for each service in part. Any idea what am I doing wrong here? -
why isn't my image being uploaded with the django form I created?
I am using Python 2.7, Django 1.9. I'm trying to get an image from the user with this model/form pair: models.py from PIL import Image class UserProfile(models.Model): user = models.OneToOneField(User) website = models.URLField(blank=True, null=True) location = models.CharField(max_length=200, null=True) longitude = models.FloatField(null=True) latitude = models.FloatField(null=True) credit = models.FloatField(default=0, null=True) picture = models.ImageField(upload_to='media/images/profile_pictures', blank=True, null=True) def __unicode__(self): return self.user.username forms.py class UserProfileForm(forms.ModelForm): class Meta: model = UserProfile fields = [ "website", "location", "picture", ] widgets = { 'location': forms.TextInput( attrs={'id': 'location', 'class': 'geo', 'required': True, 'placeholder': 'location'} ), } This is saved using the following view: def register(request): registered = False if request.method == "POST": user_form = UserForm(request.POST) profile_form = UserProfileForm(request.POST, request.FILES) if user_form.is_valid() and profile_form.is_valid(): print(request.POST['location']) print(str(request.POST['location'])) user = user_form.save() user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user profile.save() else: print user_form.errors, profile_form.errors else: profile_form = UserProfileForm() user_form = UserForm() return render(request, "register.html", {'user_form' : user_form, 'profile_form' : profil But upon execution, no pictures are saved to the folders. Here is the root of the image_urls: project/static/media/images/profile_pictures Any ideas? -
Django Makemigrations not working in version 1.10 after adding new table
I added some table models in models.py for the first time running the app and then ran python manage.py makemigrations followed by python manage.py migrate. This works well but after adding two more tables it doesn't work again. It created migrations for the changes made but when I run python manage.py migrate nothing happens. My new tables are not added to the database. Things I have done: Deleted all files in migrations folder and then run python manage.py makemigrationsfollowed by python manage.py migrate but the new tables are not still not getting added to the database even though the new table models show in the migration that was created i.e 0001_initial.py. Deleted the database followed by the steps in 1 above but it still didn't solve my problem. Only the first set of tables get created. Tried python manage.py makemigrations app_name but it still didn't help. -
Change django object name
I have UserDetailsSerializer class as shown below. I would like to change it's object name from user to data to meet API endpoint requirements on my front-end application. I tried searching through internet but wasn't quite sure how to get such result. class UserDetailsSerializer(serializers.ModelSerializer): uid = serializers.SerializerMethodField('get_username') """ User model w/o password """ class Meta: model = UserModel fields = ('uid', 'email', 'first_name', 'last_name', 'id') read_only_fields = ('email', ) def get_username(self, obj): return obj.username There are few other methods that I could think of, which are reassigning the object in the view with a different name (again, I'm not exactly sure how it works with serializers.) and changing the front-end application API requirement. Please let me know if you can help. -
Error during template rendering ProgrammingError at /admin/ column django_content_type.name does not exist
I am trying to upgrade form 1.7.4 to 1.8 and higher. Trying to go one step at a time. All steps are done except I am not able to open main admin page. I am able to open apps in the admin. But not the main admin template. Here is the error: ProgrammingError at /admin/ column django_content_type.name does not exist LINE 1: ..._user"."date_joined", "django_content_type"."id", "django_co... ^ Request Method: GET Request URL: http://test.shipler.in/admin/ Django Version: 1.7.4 Exception Type: ProgrammingError Exception Value: column django_content_type.name does not exist LINE 1: ..._user"."date_joined", "django_content_type"."id", "django_co... ^ It is the causing error while template rendering Error during template rendering In template /usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/admin/index.html, error at line 63 column django_content_type.name does not exist LINE 1: ..._user"."date_joined", "django_content_type"."id", "django_co... ^ 53 <div id="content-related"> 54 <div class="module" id="recent-actions-module"> 55 <h2>{% trans 'Recent Actions' %}</h2> 56 <h3>{% trans 'My Actions' %}</h3> 57 {% load log %} 58 {% get_admin_log 10 as admin_log for_user user %} 59 {% if not admin_log %} 60 <p>{% trans 'None available' %}</p> 61 {% else %} 62 <ul class="actionlist"> 63 **{% for entry in admin_log %}** 64 <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}"> 65 {% … -
Django Deployed Admin Account - Missing Table
My local Django app has an admin account, which I can successfully login to. However, when I deploy this app to the Google's Cloud by following this tutorial; I get the photographed error. How can I fix this? -
django-webtest throwing an error with i18n_patterns URLs
Here's my code: from django.conf import settings from django_webtest import WebTest class HomeFunctionalTests(WebTest): fixtures = ('languages',) def test_root_redirection(self): """ When visiting domain.ext/ the user must be redirected to domain.ext/en/ """ page = self.app.get(settings.SITE_URL) Error: ====================================================================== ERROR: test_root_redirection (myproj.tests.HomeFunctionalTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/adam/.pyvenv/myproj/lib/python3.5/site-packages/django/core/handlers/base.py", line 134, in get_response resolver_match = resolver.resolve(request.path_info) File "/Users/adam/.pyvenv/myproj/lib/python3.5/site-packages/django/core/urlresolvers.py", line 404, in resolve raise Resolver404({'tried': tried, 'path': new_path}) django.core.urlresolvers.Resolver404: {'path': '', 'tried': [[<RegexURLResolver <RegexURLPattern list> (admin:admin) ^darkroom/>], [<RegexURLResolver <module 'rest_framework.urls' from '/Users/adam/.pyvenv/myproj/lib/python3.5/site-packages/rest_framework/urls.py'> (rest_framework:rest_framework) ^api-auth/>], [<RegexURLResolver <RegexURLPattern list> (None:None) ^api/>], [<RegexURLPattern None ^api/tokens/>], [<RegexURLPattern documentation ^documentation/items/(?P<cat_slug>[\w-]+)/$>], [<RegexURLPattern None ^robots.txt$>], [<RegexURLPattern None ^design/400/$>], [<RegexURLPattern None ^design/403/$>], [<RegexURLPattern None ^design/404/$>], [<RegexURLPattern None ^design/500/$>], [<RegexURLPattern None ^(?P<cat>(name|namen|nombres|noms|nomes))>], [<LocaleRegexURLResolver <RegexURLPattern list> (None:None) ^en/>]]} During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/adam/.pyvenv/myproj/lib/python3.5/site-packages/django/core/handlers/base.py", line 92, in get_exception_response response = callback(request, **dict(param_dict, exception=exception)) TypeError: page_not_found() got an unexpected keyword argument 'exception' During handling of the above exception, another exception occurred: The website works via the browser correctly. -
MySQL On Update not triggering for Django/TastyPie REST API
We have a resource table which has a field last_updated which we setup with mysql-workbench to have the following properties: Datatype: TIMESTAMP NN (NotNull) is checked Default: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP When I modify a row through the workbench and apply it, the last_updated field properly updates. When I use the REST api we've setup, and issue a put: update = requests.put('http://127.0.0.1:8000/api/resources/16', data=json.dumps(dict(status="/api/status/4", timeout=timeout_time)), headers=HEADER) I can properly change any of the values (including status and timeout, and receive a 204 response), but last_updated does not update. Django's model documentation says in this case it should be sending an UPDATE. Anyone have and ideas on why it's missing these updates? I can provide further details regarding our specific Django/tastypie setup, but as long as they are issuing an UPDATE, they should be triggering the databases ON UPDATE. -
is it secure to set oauth token as cookie?
I have an angular controller that runs in a django app. I login with django but then my angular app can't authenticate to be able to invoke a service written in django rest framework. My thinking is that I authenticate with oauth in django and then write the token generated to a cookie. I can then grab the cookie in angular and use it to make my web service calls. Is this a secure good idea? -
how to get initial data on the extra forms
i got multiple forms which i want fields to pull from the same initial data but only the first formset is doing wht i want it to do and i want them all too CustomerFormset = formset_factory(CustomerForm, extra=2) form = CustomerFormset(initial=[{'Location':'USA', 'age': 10} ]) context = { 'form':form } return render(request,"Customermanager/SubProcess.html",context) so when the form loads... all the rest of the extra COME BLANK! i want both my intial plus extra to have the same data in the first field if i can get some code to do that ill happen the rest -
Django: URL not recognized? Have no idea what I'm doing wrong
So I'm making an episode tracker for tv shows, currently making the "Add show" form. When I go to localhost:8000/add, it says that that is not found. What could I possibly be doing wrong? views.py class ShowCreate(CreateView): model = Show fields = ['title', 'description', 'episode', 'season'] index.html <a href="{% url 'show:show-add' %}">Add</a> urls.py url(r'^add/$', views.ShowCreate.as_view(), name='show-add'), show_form.html {% extends 'show/base.html' %} {% block title %}Add Show{% endblock %} {% block content %} <form action="" method="post"> {% csrf_token %} <h1>Add show</h1> {% include 'show/form-template.html' %} <button>Submit</button> </form> {% endblock %} form_template.html {% for field in form %} <div class="form"> <h3>{{field.label_tag}}</h3> <div class="field">{{field}}</div> </div><!--form--> {% endfor %} -
implementation of query in django: select title, earning from task where answer.title==task.title and answer.title=='T';
i have 2 app named answer and task and i want to pick the earning and title column from task model where answer.accept_answer='T'; so the query i want to implement is : select title, earning from task where answer.title==task.title and answer.title=='T'; task.models class Task(models.Model): title = models.CharField(max_length=200) body = models.TextField(max_length=1000) earning = models.DecimalField(max_digits=6 , decimal_places=2) def __str__(self): return self.title def __unicode__(self): return self.title answer.models: class answers(models.Model): username = models.ForeignKey(settings.AUTH_USER_MODEL) title = models.ForeignKey(Task) answer = models.URLField() ANSWER_CHOICES = ( ('F', 'Declined'), ('T', 'Accepted'), ) accept_answer = models.CharField(max_length=1, choices=ANSWER_CHOICES, default='f') def __str__(self): return self.answer def __unicode__(self): return self.answer -
Is it possible for django-rest-framework view to be called without a request object?
I've inherited a Django code base using Django REST Framework that has many views that check for the existence of a request argument at the top, like this: class ExampleViewSet(viewsets.GenericViewSet): def create(self, request): if not request: return Response(status=404) This doesn't seem logical to me as I don't understand how the method can be called without a request object. I'm inclined to remove it since I haven't been able to find any documentation of this idiom. Is there some purpose I'm missing?